Merge pull request #20 from KenGrofork/main

This commit is contained in:
vastxie 2024-04-22 23:01:35 +08:00 committed by GitHub
commit 60cc6d8c1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 114 additions and 9 deletions

56
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,56 @@
name: Publish Docker image
on:
workflow_dispatch:
release:
types: [published]
repository_dispatch:
types: [trigger-docker-image]
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set timezone to Shanghai
run: sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" | sudo tee /etc/timezone
- name: Generate tag with Chinese date format
id: date
run: echo "::set-output name=date::$(date +'%y%m%d')"
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: buqian/99ai
tags: |
type=raw,value=latest
type=raw,value=${{ steps.date.outputs.date }}
type=ref,event=tag
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

43
.github/workflows/sync.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Upstream Sync
permissions:
contents: write
on:
schedule:
- cron: '0 */3 * * *' # 每3小时执行一次
workflow_dispatch:
jobs:
sync_latest_from_upstream:
name: Sync latest commits from upstream repo
runs-on: ubuntu-latest
if: ${{ github.event.repository.fork }}
steps:
- name: Checkout target repo
uses: actions/checkout@v3
- name: Sync upstream changes
id: sync
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
with:
upstream_sync_repo: vastxie/99AI
upstream_sync_branch: main
target_sync_branch: main
target_repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync check
if: failure()
run: |
echo "Sync failed."
exit 1
- name: Trigger docker-image workflow
if: steps.sync.outputs.changes_detected == 'true'
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/KenGrofork/NineAIQuickDeploy/dispatches \
-d '{"event_type": "trigger-docker-image"}'

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules
pnpm-lock.yaml
sql
data
.idea

View File

@ -1,8 +1,8 @@
# 编译阶段
FROM node:18-alpine AS build
FROM node:18-alpine AS base
FROM base AS build
WORKDIR /app
COPY . .
COPY package.json ./
# 使用腾讯源(国内服务器可取消下方注释以提升安装速度)
# RUN npm config set registry https://mirrors.cloud.tencent.com/npm/
@ -13,16 +13,21 @@ COPY . .
# 如遇到提示网站证书无效取消下方注释禁止严格SS策略
# RUN npm config set strict-ssl false
# 使用 pnpm 安装项目依赖
RUN npm install -g pnpm
RUN pnpm install
# 安装项目依赖
RUN apk add --no-cache --virtual .build-deps git && \
npm install --omit=dev && \
apk del .build-deps
# 运行阶段
FROM node:18-alpine
FROM base AS runner
ENV TZ="Asia/Shanghai"
WORKDIR /app
COPY --from=build /app .
COPY --from=build /app/node_modules ./node_modules
COPY . .
EXPOSE 9520
CMD ["node", "./dist/main.js"]