File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6060 build-and-push :
6161 runs-on : ubuntu-latest
6262 needs : test
63- if : github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
63+ if : github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || github.event_name == 'pull_request'
6464
6565 steps :
6666 - name : Checkout code
@@ -82,10 +82,16 @@ jobs:
8282 # For tags, use the tag name
8383 TAG=${GITHUB_REF#refs/tags/}
8484 echo "tags=hartmutcouk/pg-repack-docker:$TAG,hartmutcouk/pg-repack-docker:latest" >> $GITHUB_OUTPUT
85+ elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
86+ # For PRs, use PR number and short hash
87+ BRANCH_NAME="pr-${{ github.event.number }}"
88+ SHORT_HASH=$(echo ${{ github.sha }} | cut -c1-7)
89+ echo "tags=hartmutcouk/pg-repack-docker:${BRANCH_NAME}.${SHORT_HASH}" >> $GITHUB_OUTPUT
8590 else
86- # For master/main branch, use snapshot with date
87- DATE=$(date +%Y%m%d)
88- echo "tags=hartmutcouk/pg-repack-docker:snapshot-$DATE" >> $GITHUB_OUTPUT
91+ # For master/main branch commits, normalize branch name and use short hash
92+ BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')
93+ SHORT_HASH=$(echo ${{ github.sha }} | cut -c1-7)
94+ echo "tags=hartmutcouk/pg-repack-docker:${BRANCH_NAME}.${SHORT_HASH}" >> $GITHUB_OUTPUT
8995 fi
9096
9197 - name : Build and push multi-platform image
You can’t perform that action at this time.
0 commit comments