-
Notifications
You must be signed in to change notification settings - Fork 485
62 lines (53 loc) · 2.08 KB
/
Copy pathgatekeeper.yml
File metadata and controls
62 lines (53 loc) · 2.08 KB
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
name: Gatekeeper
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
pull-requests: read
checks: read
statuses: read
concurrency:
group: gatekeeper-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
all-checks-passed:
name: All Checks Passed
runs-on: ubuntu-latest
timeout-minutes: 240
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
SELF_NAME: All Checks Passed
steps:
- name: Wait for other checks to complete successfully
run: |
echo "Giving sibling workflows time to register..."
sleep 60
while true; do
CHECKS=$(gh pr view "$PR_NUMBER" -R "$REPO" --json statusCheckRollup --jq \
'[.statusCheckRollup[] | select(.name != env.SELF_NAME and .context != env.SELF_NAME)]')
PENDING=$(echo "$CHECKS" | jq '[.[] | select(
((.status // "") | test("QUEUED|IN_PROGRESS|PENDING|WAITING|REQUESTED"; "i")) or
((.state // "") | test("PENDING|EXPECTED"; "i"))
)] | length')
if [ "$PENDING" -gt 0 ]; then
echo "$PENDING checks still running. Waiting 60s..."
sleep 60
continue
fi
FAILED=$(echo "$CHECKS" | jq '[.[] | select(
((.conclusion // "") | test("FAILURE|CANCELLED|TIMED_OUT|ACTION_REQUIRED|STARTUP_FAILURE"; "i")) or
((.state // "") | test("FAILURE|ERROR"; "i"))
)] | length')
if [ "$FAILED" -gt 0 ]; then
echo "Failed checks:"
echo "$CHECKS" | jq -r '.[] | select(
((.conclusion // "") | test("FAILURE|CANCELLED|TIMED_OUT|ACTION_REQUIRED|STARTUP_FAILURE"; "i")) or
((.state // "") | test("FAILURE|ERROR"; "i"))
) | "\(.name // .context): \(.conclusion // .state)"'
exit 1
fi
echo "All triggered checks green (or skipped)."
break
done