ci: optimize workflow performance

- PR docker builds use single arch (amd64 only), tag push uses dual
- Add paths-ignore to skip CI on docs-only changes
- Add concurrency groups to cancel stale runs on re-push
- Build Go binary once instead of 3x go run in migrate job
This commit is contained in:
BBQ
2026-02-20 03:54:43 +08:00
parent 50b05be183
commit f472182b82
2 changed files with 27 additions and 4 deletions
+18 -3
View File
@@ -3,8 +3,20 @@ name: CI
on:
push:
branches: [main]
paths-ignore:
- "docs/**"
- "**.md"
- "devenv/**"
pull_request:
branches: [main]
paths-ignore:
- "docs/**"
- "**.md"
- "devenv/**"
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
@@ -33,6 +45,9 @@ jobs:
with:
go-version-file: go.mod
- name: Build
run: go build -o memoh-server ./cmd/agent
- name: Generate config
run: |
cat > config.toml <<'TOML'
@@ -46,10 +61,10 @@ jobs:
TOML
- name: Migrate up
run: go run ./cmd/agent migrate up
run: ./memoh-server migrate up
- name: Migrate down
run: go run ./cmd/agent migrate down
run: ./memoh-server migrate down
- name: Migrate up (idempotent)
run: go run ./cmd/agent migrate up
run: ./memoh-server migrate up
+9 -1
View File
@@ -5,8 +5,16 @@ on:
tags: ["v*.*.*"]
pull_request:
branches: [main]
paths-ignore:
- "docs/**"
- "**.md"
- "devenv/**"
workflow_dispatch:
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
@@ -78,7 +86,7 @@ jobs:
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
COMMIT_HASH=${{ github.sha }}