-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (118 loc) · 4.08 KB
/
ci.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: ci
on:
pull_request:
branches:
- trunk
jobs:
ping:
permissions:
contents: write
strategy:
matrix:
repo:
- toolbox
- vulkan.zig
- wayland.zig
- X11.zig
- glfw.zig
- cimgui.zig
- spirv.zig
- glslang.zig
- shaderc.zig
- spaceporn
- spaceporn-dep-action-env
- spaceporn-dep-action-bot
- spaceporn-dep-action-ci
- spaceporn-dep-action-cd-ping
- spaceporn-dep-action-cd-pong
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: "${{ github.repository_owner }}/${{ github.event.repository.name }}"
- name: Search current tag selected by user
id: used
env:
DEPENDENCY: "${{ github.repository_owner }}/${{ matrix.repo }}"
shell: bash
run: |
tag="$(grep -h -o -R "${DEPENDENCY}@v\S\+" | sed "s#^${DEPENDENCY}@##" | sort -u || :)"
printf 'tag=%s\n' "${tag}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v4
with:
repository: "${{ github.repository_owner }}/${{ matrix.repo }}"
fetch-depth: 0
fetch-tags: true
- name: Prepare dump
id: prepare
env:
USED: "${{ steps.used.outputs.tag }}"
shell: bash
run: |
tags="$(git tag --points-at "$(git describe --tags --abbrev=0 2> /dev/null)" 2> /dev/null | wc -l || :)"
if [[ -z "${tags}" || "${tags}" == '0' ]]; then tag='0.0.0'
elif [[ "${tags}" == '1' ]]; then tag="$(git describe --tags --abbrev=0)"; fi
git show-ref --tags "${tag:-"${USED}"}" --quiet && git checkout "${tag:-"${USED}"}"
printf 'tag=%s\n' "${tag:-"${USED}"}" >> "${GITHUB_OUTPUT}"
if [[ -f "${GITHUB_WORKSPACE}/build.zig" ]]
then
printf 'is_composite=false\n' >> "${GITHUB_OUTPUT}"
else
printf 'is_composite=true\n' >> "${GITHUB_OUTPUT}"
fi
- uses: actions/checkout@v4
- name: Keep the last run ID in memory
id: previous_run
env:
GH_TOKEN: "${{ github.token }}"
TITLE: "ping-${{ matrix.repo }}"
WORKFLOW_NAME: 'dump'
shell: bash
run: |
id="$(gh run list -w "${WORKFLOW_NAME}" -L 100 --json 'databaseId,displayTitle' --jq "[.[] | select(.displayTitle | contains (\"${TITLE}\")) | .databaseId] | sort | .[-1]")"
printf 'id=%s\n' "${id}" >> "${GITHUB_OUTPUT}"
- uses: ./
with:
repository_name: "${{ matrix.repo }}"
is_composite: "${{ steps.prepare.outputs.is_composite }}"
user: "${{ github.event.repository.name }}"
tag: "${{ steps.prepare.outputs.tag }}"
token: "${{ secrets.PAT }}"
- uses: actions/checkout@v4
- name: Wait for the new job to start
id: start
env:
GH_TOKEN: "${{ github.token }}"
PREVIOUS_RUN_ID: "${{ steps.previous_run.outputs.id }}"
TITLE: "ping-${{ matrix.repo }}"
WORKFLOW_NAME: 'dump'
shell: bash
run: |
while [[ -z "${id:-}" || "${id:-}" == "${PREVIOUS_RUN_ID}" ]]
do
sleep 2
id="$(gh run list -w "${WORKFLOW_NAME}" -L 100 --json 'databaseId,displayTitle' --jq "[.[] | select(.displayTitle | contains (\"${TITLE}\")) | .databaseId] | sort | .[-1]")"
done
printf 'job_id=%s\n' "${id}" >> "${GITHUB_OUTPUT}"
- name: Wait for the new job to end
id: end
env:
CONCLUSION: 'conclusion'
GH_TOKEN: "${{ github.token }}"
ID: "${{ steps.start.outputs.job_id }}"
STATUS: 'status'
shell: bash
run: |
while [[ "${status:-}" != 'completed' ]]
do
sleep 2
status="$(gh run view --json "${STATUS}" "${ID}" --jq ".${STATUS}")"
done
conclusion="$(gh run view --json "${CONCLUSION}" "${ID}" --jq ".${CONCLUSION}")"
printf 'job_result=%s\n' "${conclusion}" >> "${GITHUB_OUTPUT}"
- name: Fail if the dump failed
env:
RESULT: "${{ steps.end.outputs.job_result }}"
shell: bash
run: |
[[ "${RESULT}" == 'success' ]]