Skip to content

Commit aed9421

Browse files
committed
ci: restrict CI trigger to semantic version tags
- remove non-semantic version tag pattern from GitHub Actions workflow - ensure builds only trigger on valid semantic versioning tags like v1.2.3 Signed-off-by: mingcheng <[email protected]>
1 parent 41a033c commit aed9421

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/ghcr.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ on:
44
push:
55
branches:
66
- main
7-
- develop
87
tags:
9-
- "v*.*.*" # Semantic versioning tags (v1.0.0, v1.2.3, etc.)
8+
- "v*.*.*" # Match version tags like v1.2.3
109
pull_request:
1110
branches:
1211
- main
@@ -46,6 +45,11 @@ jobs:
4645
username: ${{ github.actor }}
4746
password: ${{ secrets.GITHUB_TOKEN }}
4847

48+
- uses: benjlevesque/[email protected]
49+
id: short-sha
50+
with:
51+
length: 7
52+
4953
- name: Extract metadata (tags, labels) for Docker
5054
id: meta
5155
uses: docker/metadata-action@v5
@@ -64,6 +68,7 @@ jobs:
6468
type=sha,format=short
6569
# Tag latest only on main branch
6670
type=raw,value=latest,enable={{is_default_branch}}
71+
type=raw,value={{steps.short-sha.outputs.sha}},enable={{is_default_branch}}
6772
labels: |
6873
org.opencontainers.image.title=aigitcommit
6974
org.opencontainers.image.description=AI-powered Git commit message generator
@@ -76,7 +81,9 @@ jobs:
7681
context: .
7782
platforms: linux/amd64,linux/arm64
7883
push: ${{ github.event_name != 'pull_request' }}
79-
tags: ${{ steps.meta.outputs.tags }}
84+
tags: |
85+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
86+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.short-sha.outputs.sha }}
8087
labels: ${{ steps.meta.outputs.labels }}
8188
cache-from: type=gha
8289
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)