@@ -44,12 +44,40 @@ jobs:
4444 egress-policy : audit
4545
4646 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+ with :
48+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
4749
4850 - name : Set current timestamp
4951 id : vars
5052 run : |
5153 echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
5254 echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
55+ echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
56+
57+ - name : Determine version and deployment context
58+ id : version
59+ run : |
60+ REPO_URL="https://github.com/${{ github.repository }}"
61+
62+ if [[ "${{ github.ref_type }}" == "tag" ]]; then
63+ # Tag deployment - display version, link to release
64+ echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
65+ echo "app_version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
66+ echo "app_version_url=${REPO_URL}/releases/tag/${{ github.ref_name }}" >> $GITHUB_OUTPUT
67+ elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
68+ # PR deployment - display pr-XXX, link to PR commit
69+ PR_NUMBER="${{ github.event.pull_request.number }}"
70+ COMMIT_HASH="${{ steps.vars.outputs.sha_full }}"
71+ echo "version=${PR_NUMBER}/merge-${COMMIT_HASH}" >> $GITHUB_OUTPUT
72+ echo "app_version=pr-${PR_NUMBER}" >> $GITHUB_OUTPUT
73+ echo "app_version_url=${REPO_URL}/pull/${PR_NUMBER}/commits/${COMMIT_HASH}" >> $GITHUB_OUTPUT
74+ else
75+ # Branch deployment - display branch name, link to commit
76+ BRANCH_NAME="${{ github.ref_name }}"
77+ COMMIT_HASH="${{ steps.vars.outputs.sha_full }}"
78+ echo "app_version=${BRANCH_NAME}" >> $GITHUB_OUTPUT
79+ echo "app_version_url=${REPO_URL}/commit/${COMMIT_HASH}" >> $GITHUB_OUTPUT
80+ fi
5381
5482 - name : Log in to the Container registry
5583 uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
@@ -87,6 +115,10 @@ jobs:
87115 push : ${{ github.event_name != 'pull_request' || env.PUSH_FROM_PR == 'true' }}
88116 tags : ${{ steps.meta.outputs.tags }}
89117 labels : ${{ steps.meta.outputs.labels }}
118+ build-args : |
119+ APP_REPOSITORY=https://github.com/${{ github.repository }}
120+ APP_VERSION=${{ steps.version.outputs.app_version }}
121+ APP_VERSION_URL=${{ steps.version.outputs.app_version_url }}
90122 cache-from : type=gha
91123 cache-to : type=gha,mode=max
92124
0 commit comments