Skip to content

Commit 67fa8f7

Browse files
committed
Unify the two trigger workflows under one
The release and build trigger workflows were sharing a lot of jobs. Therefore, unify them under one workflow file and use if statements to control which jobs will execute based on the trigger event. Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
1 parent e4c3cf7 commit 67fa8f7

2 files changed

Lines changed: 77 additions & 137 deletions

File tree

.github/workflows/build-trigger.yaml

Lines changed: 0 additions & 127 deletions
This file was deleted.
Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
name: Release Trigger
1+
name: Provide monitor artifacts
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- qemu/**
9+
- solo5/**
10+
- firecracker/**
11+
- virtiofsd/**
412
push:
513
branches:
614
- main
@@ -103,7 +111,8 @@ jobs:
103111
tag-parent:
104112
name: Tag Parent Repository
105113
needs: [check-release-existence]
106-
if: needs.check-release-existence.outputs.exists == 'false'
114+
if: ${{ github.event_name == 'push' &&
115+
needs.check-release-existence.outputs.exists == 'false' }}
107116
runs-on: ubuntu-latest
108117
permissions:
109118
contents: write
@@ -140,8 +149,7 @@ jobs:
140149
141150
build-Qemu-artifacts:
142151
name: Check and build missing Qemu artifacts
143-
needs: [get-versions,check-release-existence,tag-parent]
144-
if: needs.check-release-existence.outputs.exists == 'false'
152+
needs: [get-versions]
145153
uses: ./.github/workflows/qemu_build.yaml
146154
with:
147155
qemu_version: ${{ needs.get-versions.outputs.qemu_version }}
@@ -150,8 +158,7 @@ jobs:
150158

151159
build-Solo5-artifacts:
152160
name: Check and build missing Solo5 artifacts
153-
needs: [get-versions,check-release-existence,tag-parent]
154-
if: needs.check-release-existence.outputs.exists == 'false'
161+
needs: [get-versions]
155162
uses: ./.github/workflows/solo5_build.yaml
156163
with:
157164
solo5_version: ${{ needs.get-versions.outputs.solo5_version }}
@@ -160,8 +167,7 @@ jobs:
160167

161168
build-Virtiofsd-artifacts:
162169
name: Check and build missing Virtiofsd artifact
163-
needs: [get-versions,check-release-existence,tag-parent]
164-
if: needs.check-release-existence.outputs.exists == 'false'
170+
needs: [get-versions]
165171
uses: ./.github/workflows/virtiofsd_build.yaml
166172
with:
167173
virtiofsd_version: ${{ needs.get-versions.outputs.virtiofsd_version }}
@@ -170,8 +176,9 @@ jobs:
170176

171177
create-new-release:
172178
name: Create new release
173-
needs: [get-versions,check-release-existence,build-Qemu-artifacts,build-Solo5-artifacts,build-Virtiofsd-artifacts]
174-
if: needs.check-release-existence.outputs.exists == 'false'
179+
needs: [get-versions,check-release-existence,tag-parent,build-Qemu-artifacts,build-Solo5-artifacts,build-Virtiofsd-artifacts]
180+
if: ${{ github.event_name == 'push' &&
181+
needs.check-release-existence.outputs.exists == 'false' }}
175182
runs-on: ubuntu-latest
176183
permissions:
177184
contents: write
@@ -293,3 +300,63 @@ jobs:
293300
tag_name: ${{ needs.check-release-existence.outputs.release }}
294301
env:
295302
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
303+
304+
comment-artifact-links:
305+
name: Post links for artifacts
306+
needs: [get-versions,check-release-existence,build-Qemu-artifacts,build-Solo5-artifacts,build-Virtiofsd-artifacts]
307+
if: ${{ github.event_name == 'pull_request' &&
308+
needs.check-release-existence.outputs.exists == 'false' }}
309+
runs-on: ubuntu-latest
310+
permissions:
311+
issues: write
312+
pull-requests: write
313+
steps:
314+
315+
- name: Harden the runner (Audit all outbound calls)
316+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
317+
with:
318+
egress-policy: audit
319+
320+
- name: Set download links
321+
id: links
322+
run: |
323+
RUNS_URL="https://github.com/${{ github.repository }}/actions/runs"
324+
QEMU_LINK="${RUNS_URL}/${{ needs.build-Qemu-artifacts.outputs.artifact_run_id }}"
325+
SOLO5_LINK="${RUNS_URL}/${{ needs.build-Solo5-artifacts.outputs.artifact_run_id }}"
326+
VIRTIOFSD_LINK="${RUNS_URL}/${{ needs.build-Virtiofsd-artifacts.outputs.artifact_run_id }}"
327+
328+
FC_RELEASE_URL="https://github.com/firecracker-microvm/firecracker/releases"
329+
FC_LINK="${FC_RELEASE_URL}/download/${{ needs.get-versions.outputs.firecracker_version }}"
330+
echo "qemu=${QEMU_LINK}" >> $GITHUB_OUTPUT
331+
echo "solo5=${SOLO5_LINK}" >> $GITHUB_OUTPUT
332+
echo "virtiofsd=${VIRTIOFSD_LINK}" >> $GITHUB_OUTPUT
333+
echo "firecracker=${FC_LINK}" >> $GITHUB_OUTPUT
334+
if ${{ needs.check-release-existence.outputs.exists == 'false' }}
335+
then
336+
echo "release=" >> $GITHUB_OUTPUT
337+
else
338+
echo "release=https://github.com/${{ github.repository }}/releases/tag/${{ needs.check-release-existence.outputs.release }}" >> $GITHUB_OUTPUT
339+
fi
340+
341+
- name: Add ccomment
342+
uses: actions/github-script@v8
343+
env:
344+
QEMU_TEXT: "Qemu ${{ needs.build-Qemu-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.qemu }}"
345+
SOLO5_TEXT: "Solo5 ${{ needs.build-Solo5-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.solo5 }}"
346+
VFS_TEXT: "Virtiofsd ${{ needs.build-Virtiofsd-artifacts.outputs.artifact_suffix }}: ${{ steps.links.outputs.virtiofsd }}"
347+
FC_TEXT: "Firecracker ${{ needs.get-versions.outputs.firecracker_version }}: ${{ steps.links.outputs.firecracker }}"
348+
with:
349+
script: |
350+
const body = `
351+
Links to download artifacts for amd64 and aarch64 architectures:
352+
- ${process.env.QEMU_TEXT}
353+
- ${process.env.SOLO5_TEXT}
354+
- ${process.env.VFS_TEXT}
355+
- ${process.env.FC_TEXT}
356+
`;
357+
await github.rest.issues.createComment({
358+
issue_number: context.issue.number,
359+
owner: context.repo.owner,
360+
repo: context.repo.repo,
361+
body
362+
})

0 commit comments

Comments
 (0)