Skip to content

Commit ac3bf95

Browse files
committed
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 <charalampos.mainas@gmail.com>
1 parent 976e6cc commit ac3bf95

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Find or build artifacts from PRs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- qemu/**
9+
- solo5/**
10+
- firecracker/**
11+
- virtiofsd/**
12+
13+
jobs:
14+
get-versions:
15+
name: Get the versions of all artifacts from their respeective VERSION files
16+
runs-on: ubuntu-latest
17+
outputs:
18+
qemu_version: ${{ steps.versions.outputs.qemu_version }}
19+
solo5_version: ${{ steps.versions.outputs.solo5_version }}
20+
firecracker_version: ${{ steps.versions.outputs.firecracker_version }}
21+
virtiofsd_version: ${{ steps.versions.outputs.virtiofsd_version }}
22+
23+
steps:
24+
- name: Harden the runner (Audit all outbound calls)
25+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
26+
with:
27+
egress-policy: audit
28+
29+
- name: Checkout code
30+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Get versions to build
35+
id: versions
36+
run: |
37+
QEMU_VERSION="$(cat qemu/VERSION)"
38+
SOLO5_VERSION="$(cat solo5/VERSION)"
39+
FIRECRACKER_VERSION="$(cat firecracker/VERSION)"
40+
VIRTIOFSD_VERSION="$(cat virtiofsd/VERSION)"
41+
echo "qemu_version=$QEMU_VERSION" >> $GITHUB_OUTPUT
42+
echo "solo5_version=$SOLO5_VERSION" >> $GITHUB_OUTPUT
43+
echo "firecracker_version=$FIRECRACKER_VERSION" >> $GITHUB_OUTPUT
44+
echo "virtiofsd_version=$VIRTIOFSD_VERSION" >> $GITHUB_OUTPUT
45+
echo "$QEMU_VERSION"
46+
echo "$SOLO5_VERSION"
47+
echo "$FIRECRACKER_VERSION"
48+
echo "$VIRTIOFSD_VERSION"
49+
50+
build-Qemu-artifacts:
51+
name: Check and build missing Qemu artifacts
52+
needs: [get-versions]
53+
uses: ./.github/workflows/qemu_build.yaml
54+
with:
55+
qemu_version: ${{ needs.get-versions.outputs.qemu_version }}
56+
arch: '["amd64", "arm64"]'
57+
secrets: inherit
58+
59+
build-Solo5-artifacts:
60+
name: Check and build missing Solo5 artifacts
61+
needs: [get-versions]
62+
uses: ./.github/workflows/solo5_build.yaml
63+
with:
64+
solo5_version: ${{ needs.get-versions.outputs.solo5_version }}
65+
arch: '["amd64", "arm64"]'
66+
secrets: inherit
67+
68+
build-Virtiofsd-artifacts:
69+
name: Check and build missing Virtiofsd artifact
70+
needs: [get-versions]
71+
uses: ./.github/workflows/virtiofsd_build.yaml
72+
with:
73+
virtiofsd_version: ${{ needs.get-versions.outputs.virtiofsd_version }}
74+
arch: '["amd64", "arm64"]'
75+
secrets: inherit
76+
77+
comment-artifact-links:
78+
name: Post links for artifacts
79+
needs: [get-versions,build-Qemu-artifacts,build-Solo5-artifacts,build-Virtiofsd-artifacts]
80+
runs-on: ubuntu-latest
81+
permissions:
82+
issues: write
83+
pull-requests: write
84+
steps:
85+
86+
- name: Harden the runner (Audit all outbound calls)
87+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
88+
with:
89+
egress-policy: audit
90+
91+
- name: Set download links
92+
id: links
93+
run: |
94+
RUNS_URL="https://github.com/${{ github.repository }}/actions/runs"
95+
QEMU_LINK="${RUNS_URL}/${{ needs.build-Qemu-artifacts.outputs.artifact_run_id }}"
96+
SOLO5_LINK="${RUNS_URL}/${{ needs.build-Solo5-artifacts.outputs.artifact_run_id }}"
97+
VIRTIOFSD_LINK="${RUNS_URL}/${{ needs.build-Virtiofsd-artifacts.outputs.artifact_run_id }}"
98+
99+
FC_RELEASE_URL="https://github.com/firecracker-microvm/firecracker/releases"
100+
FC_LINK="${FC_RELEASE_URL}/download/${{ needs.get-versions.outputs.firecracker_version }}"
101+
echo "qemu=${QEMU_LINK}" >> $GITHUB_OUTPUT
102+
echo "solo5=${SOLO5_LINK}" >> $GITHUB_OUTPUT
103+
echo "virtiofsd=${VIRTIOFSD_LINK}" >> $GITHUB_OUTPUT
104+
echo "firecracker=${FC_LINK}" >> $GITHUB_OUTPUT
105+
106+
- name: Add ccomment
107+
uses: actions/github-script@v8
108+
env:
109+
QEMU_TEXT: "Qemu ${{ needs.build-Qemu-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.qemu }}"
110+
SOLO5_TEXT: "Solo5 ${{ needs.build-Solo5-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.solo5 }}"
111+
VFS_TEXT: "Virtiofsd ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.virtiofsd }}"
112+
FC_TEXT: "Firecracker ${{ needs.get-versions.outputs.firecracker_version }}: ${{ steps.links.outputs.firecracker }}"
113+
with:
114+
script: |
115+
const body = `
116+
Links to download artifacts for amd64 and aarch64 architectures:
117+
- ${process.env.QEMU_TEXT}
118+
- ${process.env.SOLO5_TEXT}
119+
- ${process.env.VFS_TEXT}
120+
- ${process.env.FC_TEXT}
121+
`;
122+
await github.rest.issues.createComment({
123+
issue_number: context.issue.number,
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
body
127+
})

0 commit comments

Comments
 (0)