From ac3bf95a1f1916e8b945d24cace30d681aa22d5d Mon Sep 17 00:00:00 2001 From: Charalampos Mainas Date: Tue, 25 Nov 2025 15:16:19 +0200 Subject: [PATCH] Add workflow To comment links of artifacts in PRs When users request o build or get the artifacts with some specific version, they can simply open a PR with the specific VERSION and this workflow will post the links to where to find the artifacts. Signed-off-by: Charalampos Mainas --- .github/workflows/build-trigger.yaml | 127 +++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 .github/workflows/build-trigger.yaml diff --git a/.github/workflows/build-trigger.yaml b/.github/workflows/build-trigger.yaml new file mode 100644 index 0000000..bf48ebd --- /dev/null +++ b/.github/workflows/build-trigger.yaml @@ -0,0 +1,127 @@ +name: Find or build artifacts from PRs + +on: + pull_request: + branches: + - main + paths: + - qemu/** + - solo5/** + - firecracker/** + - virtiofsd/** + +jobs: + get-versions: + name: Get the versions of all artifacts from their respeective VERSION files + runs-on: ubuntu-latest + outputs: + qemu_version: ${{ steps.versions.outputs.qemu_version }} + solo5_version: ${{ steps.versions.outputs.solo5_version }} + firecracker_version: ${{ steps.versions.outputs.firecracker_version }} + virtiofsd_version: ${{ steps.versions.outputs.virtiofsd_version }} + + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout code + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 0 + + - name: Get versions to build + id: versions + run: | + QEMU_VERSION="$(cat qemu/VERSION)" + SOLO5_VERSION="$(cat solo5/VERSION)" + FIRECRACKER_VERSION="$(cat firecracker/VERSION)" + VIRTIOFSD_VERSION="$(cat virtiofsd/VERSION)" + echo "qemu_version=$QEMU_VERSION" >> $GITHUB_OUTPUT + echo "solo5_version=$SOLO5_VERSION" >> $GITHUB_OUTPUT + echo "firecracker_version=$FIRECRACKER_VERSION" >> $GITHUB_OUTPUT + echo "virtiofsd_version=$VIRTIOFSD_VERSION" >> $GITHUB_OUTPUT + echo "$QEMU_VERSION" + echo "$SOLO5_VERSION" + echo "$FIRECRACKER_VERSION" + echo "$VIRTIOFSD_VERSION" + + build-Qemu-artifacts: + name: Check and build missing Qemu artifacts + needs: [get-versions] + uses: ./.github/workflows/qemu_build.yaml + with: + qemu_version: ${{ needs.get-versions.outputs.qemu_version }} + arch: '["amd64", "arm64"]' + secrets: inherit + + build-Solo5-artifacts: + name: Check and build missing Solo5 artifacts + needs: [get-versions] + uses: ./.github/workflows/solo5_build.yaml + with: + solo5_version: ${{ needs.get-versions.outputs.solo5_version }} + arch: '["amd64", "arm64"]' + secrets: inherit + + build-Virtiofsd-artifacts: + name: Check and build missing Virtiofsd artifact + needs: [get-versions] + uses: ./.github/workflows/virtiofsd_build.yaml + with: + virtiofsd_version: ${{ needs.get-versions.outputs.virtiofsd_version }} + arch: '["amd64", "arm64"]' + secrets: inherit + + comment-artifact-links: + name: Post links for artifacts + needs: [get-versions,build-Qemu-artifacts,build-Solo5-artifacts,build-Virtiofsd-artifacts] + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Set download links + id: links + run: | + RUNS_URL="https://github.com/${{ github.repository }}/actions/runs" + QEMU_LINK="${RUNS_URL}/${{ needs.build-Qemu-artifacts.outputs.artifact_run_id }}" + SOLO5_LINK="${RUNS_URL}/${{ needs.build-Solo5-artifacts.outputs.artifact_run_id }}" + VIRTIOFSD_LINK="${RUNS_URL}/${{ needs.build-Virtiofsd-artifacts.outputs.artifact_run_id }}" + + FC_RELEASE_URL="https://github.com/firecracker-microvm/firecracker/releases" + FC_LINK="${FC_RELEASE_URL}/download/${{ needs.get-versions.outputs.firecracker_version }}" + echo "qemu=${QEMU_LINK}" >> $GITHUB_OUTPUT + echo "solo5=${SOLO5_LINK}" >> $GITHUB_OUTPUT + echo "virtiofsd=${VIRTIOFSD_LINK}" >> $GITHUB_OUTPUT + echo "firecracker=${FC_LINK}" >> $GITHUB_OUTPUT + + - name: Add ccomment + uses: actions/github-script@v8 + env: + QEMU_TEXT: "Qemu ${{ needs.build-Qemu-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.qemu }}" + SOLO5_TEXT: "Solo5 ${{ needs.build-Solo5-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.solo5 }}" + VFS_TEXT: "Virtiofsd ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.virtiofsd }}" + FC_TEXT: "Firecracker ${{ needs.get-versions.outputs.firecracker_version }}: ${{ steps.links.outputs.firecracker }}" + with: + script: | + const body = ` + Links to download artifacts for amd64 and aarch64 architectures: + - ${process.env.QEMU_TEXT} + - ${process.env.SOLO5_TEXT} + - ${process.env.VFS_TEXT} + - ${process.env.FC_TEXT} + `; + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body + })