Skip to content

Commit dcdea28

Browse files
committed
Add step to retrieve and sanitize branch name in build workflow
1 parent 2bf2e14 commit dcdea28

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.github/workflows/build-dev-image.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
- name: 📦 Checkout code
2828
uses: actions/checkout@v4
2929

30+
- name: 🧰 Get branch name
31+
run: | # Get the branch name from the ref and replace non-alphanumeric characters with hyphens
32+
BRANCH=$(echo "${BRANCH_NAME#refs/heads/}" | sed -e 's/[^a-zA-Z0-9]/-/g')
33+
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
34+
3035
- name: 🏷️ Generate Docker metadata
3136
id: meta
3237
uses: docker/metadata-action@v5
@@ -43,6 +48,7 @@ jobs:
4348
type=semver,pattern=v{{major}}
4449
type=sha,format=long
4550
type=raw,value=latest,enable={{is_default_branch}}
51+
type=raw,value=${{ env.BRANCH_NAME }},priority=10
4652
annotations: |
4753
runnumber=${{ github.run_id }}
4854
sha=${{ github.sha }}

0 commit comments

Comments
 (0)