diff --git a/.github/workflows/build-yocto.yml b/.github/workflows/build-yocto.yml index ad044fb1..0468e332 100644 --- a/.github/workflows/build-yocto.yml +++ b/.github/workflows/build-yocto.yml @@ -10,6 +10,7 @@ on: env: 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 }}" jobs: kas-lock: @@ -107,7 +108,7 @@ jobs: mv ../kas/build/tmp/deploy/images/${{matrix.machine}} $img_dir # Instruct our file server to make these files available for download - url="https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${GITHUB_RUN_ID}/${{ matrix.machine }}/" + url="${BASE_ARTIFACT_URL}/${{ matrix.machine }}/" retries=8 okay=0 @@ -142,5 +143,11 @@ jobs: - name: "Print output" id: print-output run: | - echo "Downloads URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${GITHUB_RUN_ID}/" - echo "url=\"https://quic-yocto-fileserver-1029608027416.us-central1.run.app/${GITHUB_RUN_ID}/\"" >> $GITHUB_OUTPUT + echo "Downloads URL: ${BASE_ARTIFACT_URL}" + echo "url=\"${BASE_ARTIFACT_URL}\"" >> $GITHUB_OUTPUT + echo "${BASE_ARTIFACT_URL}" > build_url + - name: Upload build URL + uses: actions/upload-artifact@v4 + with: + name: build_url + path: build_url diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 00a5cabf..b2fb165d 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -1,5 +1,7 @@ name: Test PR build +run-name: "Tests triggered by PR: ${{ github.event.workflow_run.display_title }}" + on: workflow_run: workflows: ["Build on PR"] @@ -7,10 +9,50 @@ on: - completed jobs: + retrieve-build-url: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + outputs: + url: ${{ steps.set-build-url.outputs.url }} + steps: + - name: 'Download build URL' + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "build_url" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + const fs = require('fs'); + const path = require('path'); + const temp = '${{ runner.temp }}/artifacts'; + if (!fs.existsSync(temp)){ + fs.mkdirSync(temp); + } + fs.writeFileSync(path.join(temp, 'build_url.zip'), Buffer.from(download.data)); + + - name: 'Setup build URL' + id: set-build-url + run: | + unzip "${{ runner.temp }}/artifacts/build_url.zip" + BUILD_URL=$(cat build_url) + echo "Build URL: ${BUILD_URL}" + echo "url=${BUILD_URL}" >> $GITHUB_OUTPUT + test: uses: ./.github/workflows/test.yml secrets: inherit - if: ${{ github.event.workflow_run.conclusion == 'success' }} + needs: retrieve-build-url with: - url: ${{ github.event.workflow_run.outputs.artifacts_url }} + url: ${{ needs.retrieve-build-url.outputs.url }}