From 77579a5a9c4d73c8457d84eadef2e10dcbe58400 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 7 Jun 2023 21:01:28 +0800 Subject: [PATCH] feat: add build webui into ci. Change Dockerfile, add webui in release draft. --- .github/workflows/dev-latest.yml | 37 ++++++++++++++++- .github/workflows/docker.yml | 70 ++++++++++++++++++++++++++++++-- Dockerfile | 6 +-- 3 files changed, 106 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dev-latest.yml b/.github/workflows/dev-latest.yml index 30b7d5dd..c8247914 100644 --- a/.github/workflows/dev-latest.yml +++ b/.github/workflows/dev-latest.yml @@ -27,7 +27,36 @@ jobs: mkdir -p config pytest - dev-latest: + build-webui: + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: latest + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: latest + run_install: true + + - name: Build + run: pnpm build && zip -r dist.zip dist + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist.zip + + + dev-build: runs-on: ubuntu-latest needs: [test] steps: @@ -44,6 +73,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: dist + path: dist.zip + - name: Docker metadata id: meta uses: docker/metadata-action@v4 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 628420be..b60e8da6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -26,19 +26,77 @@ jobs: run: | mkdir -p config pytest - - build: + build-webui: runs-on: ubuntu-latest needs: [test] steps: - name: Checkout uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: latest + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: latest + run_install: true + + - name: Build + run: pnpm build && zip -r dist.zip dist + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist.zip + + + draft-release: + runs-on: ubuntu-latest + needs: [test] + if: > + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'main' + steps: + + - name: Checkout code + uses: actions/checkout@v2 + + - name: download artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: dist.zip + + - name: Generate Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.pull_request.title }} + name: 🌟${{ github.event.pull_request.title }} + body: ${{ github.event.pull_request.body }} + draft: true + prerelease: false + files: | + dist.zip + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + build-docker: + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create Version info working-directory: ./backend/src run: | echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py - - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -46,6 +104,12 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 + - name: download artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: dist.zip + - name: Docker metadata id: meta uses: docker/metadata-action@v4 diff --git a/Dockerfile b/Dockerfile index 72de73c7..e380e5bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ ENV S6_SERVICES_GRACETIME=30000 \ WORKDIR /app COPY backend/requirements.txt . +COPY dist.zip . RUN apk add --no-cache \ bash \ ca-certificates \ @@ -34,9 +35,8 @@ RUN apk add --no-cache \ python3 -m pip install --upgrade pip && \ sed -i '/bcrypt/d' requirements.txt && \ pip install --no-cache-dir -r requirements.txt && \ - # Download WebUI - curl -sL "https://github.com/Rewrite0/Auto_Bangumi_WebUI/releases/latest/download/dist.zip" | busybox unzip -q -d /app - && \ - mv /app/dist /app/templates && \ + # Unzip WebUI \ + unzip dist.zip -d /app/templates && \ # Add user addgroup -S ab -g 911 && \ adduser -S ab -G ab -h /ab -s /bin/bash -u 911 && \