-
Notifications
You must be signed in to change notification settings - Fork 122
88 lines (77 loc) · 3.09 KB
/
PR.yml
File metadata and controls
88 lines (77 loc) · 3.09 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
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
name: PR
on:
pull_request:
branches: [master]
types: [labeled, synchronize]
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
gate:
name: Skip duplicates
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip.outputs.should_skip }}
steps:
- name: Wait a bit for label storms
if: ${{ github.event.action == 'labeled' }}
run: sleep 10
- name: Only run latest workflow-run for this PR
id: skip
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number }}
RUN_ID: ${{ github.run_id }}
WF_REF: ${{ github.workflow_ref }}
run: |
set -euo pipefail
# github.workflow_ref looks like this, so we extract filename:
# owner/repo/.github/workflows/pr.yml@refs/pull/123/merge
wf_path="$(echo "$WF_REF" | sed -E 's#^[^/]*/[^/]*/##; s#@.*$##')" # .github/workflows/PR.yml
wf_file="$(basename "$wf_path")"
echo "workflow file: $wf_file"
latest_id=$(
gh api "/repos/$REPO/actions/workflows/$wf_file/runs?per_page=50" \
| jq -r --arg PR "$PR" '
.workflow_runs
| map(select(.pull_requests | any(.number == ($PR|tonumber))))
| sort_by(.run_number)
| last
| .id
'
)
echo "latest_id=$latest_id current=$RUN_ID"
if [ -n "$latest_id" ] && [ "$latest_id" != "$RUN_ID" ]; then
echo "should_skip=true" >> "$GITHUB_OUTPUT"
else
echo "should_skip=false" >> "$GITHUB_OUTPUT"
fi
check:
needs: gate
if: ${{ needs.gate.outputs.should_skip != 'true' }}
uses: ./.github/workflows/check.yml
secrets: inherit
build:
needs: gate
if: ${{ needs.gate.outputs.should_skip != 'true' }}
uses: ./.github/workflows/build.yml
secrets: inherit
with:
macos: ${{ contains(github.event.pull_request.labels.*.name, 'E2-forcemacos') }}
windows: ${{ contains(github.event.pull_request.labels.*.name, 'E1-forcenatwin') }}
linux-aarch64: ${{ contains(github.event.pull_request.labels.*.name, 'E5-forcelinuxaarch64') }}
release: ${{ contains(github.event.pull_request.labels.*.name, 'E3-forcerelease') }}
production: ${{ contains(github.event.pull_request.labels.*.name, 'E4-forceproduction') }}
validator:
needs: gate
if: ${{ needs.gate.outputs.should_skip != 'true' && contains(github.event.pull_request.labels.*.name, 'check-validator') }}
uses: ./.github/workflows/validation.yml
secrets:
VARA_VALIDATOR_8: ${{ secrets.VARA_VALIDATOR_8 }}
SSH_VARA_USERNAME: ${{ secrets.SSH_VARA_USERNAME }}
VARA_SSH_PRIVATE_KEY: ${{ secrets.VARA_SSH_PRIVATE_KEY }}
check-node-sync:
needs: gate
if: ${{ needs.gate.outputs.should_skip != 'true' && contains(github.event.pull_request.labels.*.name, 'check-node-sync') }}
uses: ./.github/workflows/check-node-sync.yml