File tree 2 files changed +60
-1
lines changed
2 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 36
36
37
37
**PR MUST BE MERGED WITH MERGE COMMIT - ADMIN MUST ENABLE THE OPTION**
38
38
token : ${{secrets.GITHUB_TOKEN}}
39
- labels : changing-submodules-on-purpose
39
+ labels :
40
+ changing-submodules-on-purpose, sl-require-admin-action
40
41
41
42
# The next step is necessary to force the CI to be executed when a PR is opened by the github-bot.
42
43
# The PR event isn't triggered when the bot opens the PR and as such doesn't trigger the workflows that use the event as their trigger.
Original file line number Diff line number Diff line change
1
+ name : Check for sl-require-admin-action label
2
+
3
+ on :
4
+ pull_request :
5
+ branches :
6
+ - main
7
+ - release_*
8
+ types :
9
+ - opened
10
+ - reopened
11
+ - synchronize
12
+ - labeled
13
+ - unlabeled
14
+
15
+ permissions :
16
+ pull-requests : write
17
+
18
+ jobs :
19
+ check-label :
20
+ runs-on : ubuntu-latest
21
+ steps :
22
+ - name : Check for sl-require-admin-action label
23
+ run : |
24
+ PR_NUMBER=${{ github.event.pull_request.number }}
25
+ LABELS=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json labels --jq '.labels[].name')
26
+ if echo "$LABELS" | grep -q "sl-require-admin-action"; then
27
+ echo "The sl-require-admin-action label is present. Failing the job."
28
+ COMMENTS=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json comments --jq '.comments[].body')
29
+ if ! echo "$COMMENTS" | grep -q "The CI failure for this job is normal. An admin must do the merge."; then
30
+ gh pr comment $PR_NUMBER --repo ${{ github.repository }} --body "The CI failure for this job is normal. An admin must do the merge."
31
+ fi
32
+ exit 1
33
+ else
34
+ echo "The sl-require-admin-action label is not present. Passing the job."
35
+ fi
36
+ env :
37
+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
38
+
39
+ prevent-label-removal :
40
+ runs-on : ubuntu-latest
41
+ steps :
42
+ - name : Prevent sl-require-admin-action label removal
43
+ if : github.event.action == 'unlabeled'
44
+ run : |
45
+ PR_NUMBER=${{ github.event.pull_request.number }}
46
+ REMOVED_LABEL=${{ github.event.label.name }}
47
+ if [ "$REMOVED_LABEL" == "sl-require-admin-action" ]; then
48
+ echo "The sl-require-admin-action label cannot be removed. Failing the job."
49
+ COMMENTS=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json comments --jq '.comments[].body')
50
+ if ! echo "$COMMENTS" | grep -q "The sl-require-admin-action label cannot be removed once it has been added."; then
51
+ gh pr comment $PR_NUMBER --repo ${{ github.repository }} --body "The sl-require-admin-action label cannot be removed once it has been added."
52
+ fi
53
+ exit 1
54
+ else
55
+ echo "A different label was removed. Passing the job."
56
+ fi
57
+ env :
58
+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
You can’t perform that action at this time.
0 commit comments