-
Notifications
You must be signed in to change notification settings - Fork 6
78 lines (69 loc) · 3.38 KB
/
pr_image_links.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
# Use the latest published version of the cirrus-ci_retrospective container
# to determine the execution context of _this_ workflow run. If it is a
# pull request, post the artifact URLs so it is easy to download and test.
on:
check_suite: # ALWAYS triggered from the default branch
# Ref: https://help.github.com/en/actions/reference/events-that-trigger-workflows#check-suite-event-check_suite
types:
- completed
jobs:
comment_image_id:
# Do not execute for other github applications, only works with cirrus-ci
if: github.event.check_suite.app.name == 'Cirrus CI'
runs-on: ubuntu-latest
env:
# This is the last component of the gist URL
# i.e. https://gist.github.com/<user>/<id>
built_images_gist_id: f505b6fb78db279855862e035629f8aa
steps:
- name: Execute latest upstream cirrus-ci_retrospective
uses: docker://quay.io/libpod/cirrus-ci_retrospective:latest
env:
GITHUB_TOKEN: ${{ github.token }}
# Writes $GITHUB_WORKSPACE/cirrus-ci_retrospective.json
- name: Debug cirrus-ci_retrospective JSON
run: jq --indent 4 --color-output . $GITHUB_WORKSPACE/cirrus-ci_retrospective.json
- name: Load JSON into github workflow output variables
id: retro
run: |
ccirjson=$GITHUB_WORKSPACE/cirrus-ci_retrospective.json
prn=$(jq --raw-output \
'.[] | select(.name == "'success'") | .build.pullRequest' \
"$ccirjson")
bid=$(jq --raw-output \
'.[] | select(.name == "'success'") | .build.id' \
"$ccirjson")
status=$(jq --raw-output \
'.[] | select(.name == "'success'") | .status' \
"$ccirjson")
if [[ -n "$prn" ]] && \
[[ "$prn" != "null" ]] && \
[[ $prn -gt 0 ]] && \
[[ "$status" == "COMPLETED" ]]
then
printf "prn=%s\n" "$prn" >> $GITHUB_OUTPUT
printf "bid=%s\n" "$bid" >> $GITHUB_OUTPUT
printf "is_pr=%s\n" "true" >> $GITHUB_OUTPUT
else
printf "prn=%s\n" "0" >> $GITHUB_OUTPUT
printf "bid=%s\n" "0" >> $GITHUB_OUTPUT
printf "is_pr=%s\n" "false" >> $GITHUB_OUTPUT
fi
- if: steps.retro.outputs.is_pr == 'true'
uses: actions/checkout@v4
with:
persist-credentials: false
- if: steps.retro.outputs.is_pr == 'true'
name: Print Artifacts output
id: artifact_output
run: ./contrib/cirrus/print-artifacts-urls.sh "${{ steps.retro.outputs.bid }}"
- if: steps.retro.outputs.is_pr == 'true'
name: Count the number of manifest.json files downloaded
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ steps.retro.outputs.prn }}
# the tag causes it to replace the comment
comment-tag: artifacts
mode: recreate
message: ${{ steps.artifact_output.outputs.stdout }}