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
This commit is contained in:
siujamo committed 2026-08-31 13:54:20 +08:00
1 parent ed72045f5e
commit f3e31d1a06
1 file changed
+34 -31
+34 -31
View File
@@ -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: .