From 39a5a31103da472ad5597fb9d78d178de15c9d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Thu, 3 Apr 2025 10:30:30 +0200 Subject: [PATCH] workflows: Use unique build ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Loïc Minier --- .github/workflows/build-yocto.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-yocto.yml b/.github/workflows/build-yocto.yml index bb35e4326..b0994f14e 100644 --- a/.github/workflows/build-yocto.yml +++ b/.github/workflows/build-yocto.yml @@ -8,9 +8,10 @@ on: value: ${{ jobs.create-output.outputs.url }} env: + BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }} CACHE_DIR: /srv/gh-runners/quic-yocto KAS_REPO_REF_DIR: /srv/gh-runners/quic-yocto/kas-mirrors - BASE_ARTIFACT_URL: "https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${{ github.run_id }}" + BASE_ARTIFACT_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app jobs: kas-mirror: @@ -113,7 +114,7 @@ jobs: - name: Publish image run: | - build_dir=${CACHE_DIR}/builds/${GITHUB_RUN_ID} + build_dir=${CACHE_DIR}/builds/${BUILD_ID} mkdir -p $build_dir img_dir=$build_dir/${{ matrix.machine }} [ -d $img_dir ] && rm -rf $img_dir @@ -122,7 +123,7 @@ jobs: mv $deploy_dir $img_dir # Instruct our file server to make these files available for download - url="${BASE_ARTIFACT_URL}/${{ matrix.machine }}/" + url="${BASE_ARTIFACT_URL}/${BUILD_ID}/${{ matrix.machine }}/" retries=8 okay=0 @@ -157,9 +158,10 @@ jobs: - name: "Print output" id: print-output run: | - echo "Downloads URL: ${BASE_ARTIFACT_URL}" - echo "url=\"${BASE_ARTIFACT_URL}\"" >> $GITHUB_OUTPUT - echo "${BASE_ARTIFACT_URL}" > build_url + build_url="${BASE_ARTIFACT_URL}/${BUILD_ID}" + echo "Downloads URL: ${build_url}" + echo "url=\"${build_url}\"" >> $GITHUB_OUTPUT + echo "${build_url}" > build_url - name: Upload build URL uses: actions/upload-artifact@v4 with: