Skip to content

Commit 6b3af65

Browse files
authored
workflows: Use unique build ids (#823)
Build ids on the fileserver simply used the GITHUB_RUN_ID, but it is not guaranteed to be unique, and other repositories and workflows share the same tree. Change build ids to be prefixed with the GITHUB_REPOSITORY name, and suffixed with the GITHUB_RUN_ATTEMPT (in case the run has been given back). This is still safe from the perspective of directory names and URLs as GitHub prevents org and repo names to start with a dash, and use only alphanumeric chars plus single dashes.
2 parents 987c99a + 39a5a31 commit 6b3af65

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.github/workflows/build-yocto.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ on:
88
value: ${{ jobs.create-output.outputs.url }}
99

1010
env:
11+
BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
1112
CACHE_DIR: /srv/gh-runners/quic-yocto
1213
KAS_REPO_REF_DIR: /srv/gh-runners/quic-yocto/kas-mirrors
13-
BASE_ARTIFACT_URL: "https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${{ github.run_id }}"
14+
BASE_ARTIFACT_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app
1415

1516
jobs:
1617
kas-mirror:
@@ -113,7 +114,7 @@ jobs:
113114
114115
- name: Publish image
115116
run: |
116-
build_dir=${CACHE_DIR}/builds/${GITHUB_RUN_ID}
117+
build_dir=${CACHE_DIR}/builds/${BUILD_ID}
117118
mkdir -p $build_dir
118119
img_dir=$build_dir/${{ matrix.machine }}
119120
[ -d $img_dir ] && rm -rf $img_dir
@@ -122,7 +123,7 @@ jobs:
122123
mv $deploy_dir $img_dir
123124
124125
# Instruct our file server to make these files available for download
125-
url="${BASE_ARTIFACT_URL}/${{ matrix.machine }}/"
126+
url="${BASE_ARTIFACT_URL}/${BUILD_ID}/${{ matrix.machine }}/"
126127
127128
retries=8
128129
okay=0
@@ -157,9 +158,10 @@ jobs:
157158
- name: "Print output"
158159
id: print-output
159160
run: |
160-
echo "Downloads URL: ${BASE_ARTIFACT_URL}"
161-
echo "url=\"${BASE_ARTIFACT_URL}\"" >> $GITHUB_OUTPUT
162-
echo "${BASE_ARTIFACT_URL}" > build_url
161+
build_url="${BASE_ARTIFACT_URL}/${BUILD_ID}"
162+
echo "Downloads URL: ${build_url}"
163+
echo "url=\"${build_url}\"" >> $GITHUB_OUTPUT
164+
echo "${build_url}" > build_url
163165
- name: Upload build URL
164166
uses: actions/upload-artifact@v4
165167
with:

0 commit comments

Comments
 (0)