1- name : Frontend Main
1+ name : Main CI-Frontend
22
33on :
44 workflow_dispatch :
3131 with :
3232 fetch-depth : 0
3333
34+ - name : Set lowercase repo name
35+ id : repo
36+ run : echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
37+
3438 - name : Generate version tag
3539 id : version
3640 run : |
@@ -49,26 +53,26 @@ jobs:
4953 username : ${{ github.actor }}
5054 password : ${{ secrets.GITHUB_TOKEN }}
5155
52- - name : Extract metadata for Docker
53- id : meta
54- uses : docker/metadata-action@v5
55- with :
56- images : ghcr.io/${{ github.repository }}/app
57- tags : |
58- type=raw,value=${{ steps.version.outputs.tag }}
59- type=raw,value=latest,enable={{is_default_branch}}
56+ - name : Find PR number
57+ id : find_pr
58+ env :
59+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60+ run : |
61+ PR_NUMBER=$(gh pr list --search "${{ github.sha }}" --state merged --json number --jq '.[0].number')
62+ if [ -z "$PR_NUMBER" ]; then
63+ echo "No merged PR found for this commit. Falling back to 'candidate' tag."
64+ PR_NUMBER="candidate"
65+ else
66+ PR_NUMBER="pr-${PR_NUMBER}"
67+ fi
68+ echo "tag=${PR_NUMBER}" >> $GITHUB_OUTPUT
6069
61- - name : Build and push Docker image
62- uses : docker/build-push-action@v5
63- with :
64- context : ./client
65- push : true
66- tags : ${{ steps.meta.outputs.tags }}
67- labels : ${{ steps.meta.outputs.labels }}
68- cache-from : type=gha
69- cache-to : type=gha,mode=max
70- build-args : |
71- VITE_BUILD=v${{ steps.version.outputs.tag }}
70+ - name : Promote Docker image
71+ run : |
72+ docker buildx imagetools create \
73+ --tag ghcr.io/${{ steps.repo.outputs.name }}/app:latest \
74+ --tag ghcr.io/${{ steps.repo.outputs.name }}/app:${{ steps.version.outputs.tag }} \
75+ ghcr.io/${{ steps.repo.outputs.name }}/app:${{ steps.find_pr.outputs.tag }}
7276
7377 - name : Create and push Git tag
7478 run : |
0 commit comments