Skip to content

Commit ca4c95c

Browse files
committed
build: add workflow to prevent a PR being merged
1 parent 0b89aa1 commit ca4c95c

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

.github/workflows/do_not_merge.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2024 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Workflow name:
20+
name: do_not_merge
21+
22+
# Workflow triggers:
23+
on:
24+
pull_request:
25+
types: [ synchronize, opened, reopened, labeled, unlabeled ]
26+
27+
# Workflow jobs:
28+
jobs:
29+
30+
# Define a job which fails a pull request if the pull request has a "Do Not Merge" label:
31+
do_not_merge:
32+
33+
# Define job name:
34+
name: 'Check for label'
35+
36+
# Only run this job if the pull request has a "Do Not Merge" label:
37+
if: ${{ contains(github.event.*.labels.*.name, 'Do Not Merge') }}
38+
39+
# Define job permissions:
40+
permissions:
41+
contents: read
42+
pull-requests: write
43+
44+
# Define the type of virtual host machine:
45+
runs-on: ubuntu-latest
46+
47+
# Define the sequence of job steps:
48+
steps:
49+
50+
# Fail the pull request:
51+
- name: 'Prevent merge'
52+
run: |
53+
echo "Pull request is labeled as 'Do Not Merge'."
54+
echo "This workflow fails so that the pull request cannot be merged."
55+
exit 1

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#/
1818

1919
# Workflow name:
20-
name: 'labeler'
20+
name: labeler
2121

2222
# Workflow triggers:
2323
on:

0 commit comments

Comments
 (0)