From f3e31d1a0688d306cd70b288b6e557df6c3ea40a Mon Sep 17 00:00:00 2001 From: siujamo Date: Mon, 31 Aug 2026 13:54:20 +0800 Subject: [PATCH] ci(actions): simplify docker workflow paths - split workflow into pr-build and publish jobs - run quick docker build only for pull requests - keep lint and multi-arch publish on push/tag events - add pnpm setup action and remove corepack step --- .github/workflows/docker-build-push.yml | 65 +++++++++++++------------ 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 27c4815..253d2e7 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -16,41 +16,17 @@ env: IMAGE_NAME: prototype-manager jobs: - docker: + pr-build: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest - steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up Node.js - if: github.event_name != 'pull_request' - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: pnpm - - - name: Enable Corepack - if: github.event_name != 'pull_request' - run: corepack enable - - - name: Install dependencies - if: github.event_name != 'pull_request' - run: pnpm install --frozen-lockfile - - - name: Run lint - if: github.event_name != 'pull_request' - run: pnpm lint - - - name: Set up QEMU - if: github.event_name != 'pull_request' - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build image (PR only, quick validation, no push) - if: github.event_name == 'pull_request' + - name: Build image (PR only, no push) uses: docker/build-push-action@v6 with: context: . @@ -59,8 +35,38 @@ jobs: cache-from: type=gha,scope=${{ github.ref_name }} cache-to: type=gha,mode=max,scope=${{ github.ref_name }} + publish: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run lint + run: pnpm lint + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to GHCR - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -68,14 +74,12 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Docker Hub - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract Docker metadata - if: github.event_name != 'pull_request' id: meta uses: docker/metadata-action@v5 with: @@ -90,7 +94,6 @@ jobs: type=raw,value=latest,enable={{is_default_branch}} - name: Build and push image (multi-arch) - if: github.event_name != 'pull_request' uses: docker/build-push-action@v6 with: context: .