Skip to content

Commit 2796cd7

Browse files
committed
ci: use path hashing for pr image tags
1 parent 6bf625c commit 2796cd7

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,30 @@ jobs:
248248
github.event_name == 'pull_request' ||
249249
((github.event_name == 'push' || github.event_name == 'schedule') && needs.retag-and-push.outputs.image-exists == 'false')
250250
)
251-
uses: ./.github/workflows/routine-buildimage.yml
252-
permissions:
253-
packages: write
254-
with:
255-
tag: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'latest' }}
256-
cr-namespace-repository: ${{ vars.CR_NAMESPACE_REPOSITORY }}
257-
secrets: inherit
251+
runs-on: ubuntu-latest
252+
253+
outputs:
254+
image-tag: ${{ steps.generate-tag.outputs.tag }}
255+
256+
steps:
257+
- uses: actions/checkout@v4
258+
259+
- name: Generate content-based image tag
260+
id: generate-tag
261+
run: |
262+
hash=$(find src build scripts -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
263+
if [ '${{ github.event_name }}' = 'pull_request' ]; then
264+
echo "tag=pr-${{ github.event.number }}-${hash:0:8}" >> $GITHUB_OUTPUT
265+
else
266+
echo "tag=latest" >> $GITHUB_OUTPUT
267+
fi
268+
269+
- name: Call build workflow
270+
uses: ./.github/workflows/routine-buildimage.yml
271+
with:
272+
tag: ${{ steps.generate-tag.outputs.tag }}
273+
cr-namespace-repository: ${{ vars.CR_NAMESPACE_REPOSITORY }}
274+
secrets: inherit
258275

259276
deploy-to-environment:
260277
needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image, retag-and-push]
@@ -291,7 +308,7 @@ jobs:
291308
uses: ./.github/workflows/routine-runtests.yml
292309
with:
293310
headless-mode: true
294-
test-environment: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'latest' }}
311+
test-environment: ${{ needs.build-docker-image.outputs.image-tag || 'latest' }}
295312
github-issue-number: ${{ github.event.number || '' }}
296313
secrets:
297314
USER_A_USERNAME: ${{ vars.TEST_USER_A_USERNAME }}

0 commit comments

Comments
 (0)