-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (92 loc) · 3.77 KB
/
Copy pathrequired-checks.yml
File metadata and controls
98 lines (92 loc) · 3.77 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
89
90
91
92
93
94
95
96
97
98
name: Required Checks
# This workflow demonstrates required checks at three stages of the merge lifecycle:
#
# (A) push — runs whenever commits are pushed to any branch.
# Configure as a required status check on the base branch so that
# a branch must pass this check before a PR can be enqueued.
#
# (B) pull_request — runs when a PR is opened or updated.
# Configure as a required status check on the base branch so that
# the PR must pass this check before it can be enqueued.
#
# (C) merge_group — runs after a PR enters the merge queue, but before it is
# merged. If this check fails the PR is dequeued and the merge
# is blocked.
#
# Pass/fail is controlled by the `checks` file in the repository root.
# Each check looks for its own token in that file:
# push check → looks for the word "push"
# PR check → looks for the word "pr"
# merge-queue check → looks for the word "merge_queue"
#
# To make a check pass, ensure its token is present in the `checks` file.
# To make a check fail, remove its token from the `checks` file.
on:
push:
pull_request:
merge_group:
permissions:
contents: read
jobs:
# -----------------------------------------------------------------------
# (A) Push check
# Passes when the word "push" appears in the `checks` file.
# Runs on every push. Add "Push Check" as a required status check in your
# branch-protection rule to block enqueuing until this check passes.
# -----------------------------------------------------------------------
push-check:
name: Push Check
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run push check
run: |
if grep -qw "push" checks; then
echo "Push check passed ('push' found in checks file)"
else
echo "Push check failed ('push' not found in checks file)"
exit 1
fi
# -----------------------------------------------------------------------
# (B) Pull-request check
# Passes when the word "pr" appears in the `checks` file.
# Runs when a PR is opened or updated. Add "PR Check" as a required status
# check in your branch-protection rule to block enqueuing until this passes.
# -----------------------------------------------------------------------
pr-check:
name: PR Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run PR check
run: |
if grep -qw "pr" checks; then
echo "PR check passed ('pr' found in checks file)"
else
echo "PR check failed ('pr' not found in checks file)"
exit 1
fi
# -----------------------------------------------------------------------
# (C) Merge-queue check
# Passes when the word "merge_queue" appears in the `checks` file.
# Runs after the PR is added to the merge queue (merge_group event).
# Add "Merge Queue Check" as a required merge-queue check in your
# branch-protection rule. If this check fails the PR is removed from the
# queue and the merge is blocked.
# -----------------------------------------------------------------------
merge-queue-check:
name: Merge Queue Check
if: github.event_name == 'merge_group'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run merge-queue check
run: |
if grep -qw "merge_queue" checks; then
echo "Merge queue check passed ('merge_queue' found in checks file)"
else
echo "Merge queue check failed ('merge_queue' not found in checks file)"
exit 1
fi