From 4a3212cb69fe6762ff3e27cce0aae40c728922f0 Mon Sep 17 00:00:00 2001 From: Delton Ding Date: Thu, 9 Jul 2026 15:40:17 +0800 Subject: [PATCH 1/3] ci: add docker image push --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e165beb..86d1a52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,8 @@ on: push: branches: - main + tags: + - "*" concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} @@ -91,6 +93,9 @@ jobs: needs: - backend - frontend + permissions: + contents: read + packages: write steps: - name: Checkout @@ -99,12 +104,35 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Prepare image name + id: image + shell: bash + run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.name }} + tags: | + type=ref,event=tag + type=sha,prefix=sha- + + - name: Log in to GitHub Container Registry + if: startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build application image uses: docker/build-push-action@v6 with: context: . file: Dockerfile - push: false - tags: upopoy:ci + push: ${{ startsWith(github.ref, 'refs/tags/') }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max From efb240f8bfb5f8e7fec35c640d3b6bcd8877745b Mon Sep 17 00:00:00 2001 From: Delton Ding Date: Thu, 9 Jul 2026 15:45:26 +0800 Subject: [PATCH 2/3] security fix --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86d1a52..7950aed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,9 @@ concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: read + jobs: backend: name: Backend tests @@ -90,6 +93,32 @@ jobs: docker: name: Docker build runs-on: ubuntu-latest + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + needs: + - backend + - frontend + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build application image + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: false + tags: upopoy:ci + cache-from: type=gha + cache-to: type=gha,mode=max + + docker-push: + name: Docker image publish + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/') }} needs: - backend - frontend @@ -119,7 +148,6 @@ jobs: type=sha,prefix=sha- - name: Log in to GitHub Container Registry - if: startsWith(github.ref, 'refs/tags/') uses: docker/login-action@v3 with: registry: ghcr.io @@ -131,7 +159,7 @@ jobs: with: context: . file: Dockerfile - push: ${{ startsWith(github.ref, 'refs/tags/') }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha From 29c4dbfcb895c94f2170dbe076345c6074895314 Mon Sep 17 00:00:00 2001 From: Delton Ding Date: Thu, 9 Jul 2026 15:51:09 +0800 Subject: [PATCH 3/3] ag --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7950aed..0a4a3f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: branches: - main tags: - - "*" + - "v*" concurrency: group: ci-${{ github.workflow }}-${{ github.ref }}