11# /
22# @license Apache-2.0
33#
4- # Copyright (c) 2024 The Stdlib Authors.
4+ # Copyright (c) 2025 The Stdlib Authors.
55#
66# Licensed under the Apache License, Version 2.0 (the "License");
77# you may not use this file except in compliance with the License.
@@ -23,29 +23,31 @@ name: autoclose
2323on :
2424 pull_request_target :
2525 types :
26+ - opened
27+ - synchronize
2628 - labeled
29+ - unlabeled
2730
2831# Workflow jobs:
2932jobs :
30-
3133 # Define a job which closes a pull request if a contributor failed to setup EditorConfig:
3234 editorconfig :
33-
3435 # Define job name:
35- name : ' Check for EditorConfig label'
36-
37- # Only run this job if the pull request has a specific label:
38- if : " ${{ github.event.label.name == 'autoclose: EditorConfig' }}"
36+ name : " Check for EditorConfig label"
3937
4038 # Define the type of virtual host machine:
4139 runs-on : ubuntu-latest
4240
4341 # Define the sequence of job steps:
4442 steps :
45-
46- # Close the pull request:
47- - name : ' Close pull request'
48- run : gh pr close "$NUMBER" --comment "$BODY"
43+ # Close the pull request if the label is present, otherwise mark as successful:
44+ - name : " Close pull request or mark as successful"
45+ run : |
46+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: EditorConfig') }}" == "true" ]]; then
47+ gh pr close "$NUMBER" --comment "$BODY"
48+ else
49+ echo "Check for 'autoclose: EditorConfig' label passed."
50+ fi
4951 env :
5052 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
5153 GH_REPO : ${{ github.repository }}
@@ -61,22 +63,22 @@ jobs:
6163
6264 # Define a job which closes a pull request if a contributor failed to follow contributing guidelines:
6365 contributor_guidelines :
64-
6566 # Define job name:
66- name : ' Check for contributor guidelines label'
67-
68- # Only run this job if the pull request has a specific label:
69- if : " ${{ github.event.label.name == 'autoclose: Contributor Guidelines' }}"
67+ name : " Check for contributor guidelines label"
7068
7169 # Define the type of virtual host machine:
7270 runs-on : ubuntu-latest
7371
7472 # Define the sequence of job steps:
7573 steps :
76-
77- # Close the pull request:
78- - name : ' Close pull request'
79- run : gh pr close "$NUMBER" --comment "$BODY"
74+ # Close the pull request if the label is present, otherwise mark as successful:
75+ - name : " Close pull request or mark as successful"
76+ run : |
77+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: Contributor Guidelines') }}" == "true" ]]; then
78+ gh pr close "$NUMBER" --comment "$BODY"
79+ else
80+ echo "Check for 'autoclose: Contributor Guidelines' label passed."
81+ fi
8082 env :
8183 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
8284 GH_REPO : ${{ github.repository }}
@@ -92,22 +94,22 @@ jobs:
9294
9395 # Define a job which closes a pull request if a contributor failed to follow project conventions:
9496 project_conventions :
95-
9697 # Define job name:
97- name : ' Check for project conventions label'
98-
99- # Only run this job if the pull request has a specific label:
100- if : " ${{ github.event.label.name == 'autoclose: Project Conventions' }}"
98+ name : " Check for project conventions label"
10199
102100 # Define the type of virtual host machine:
103101 runs-on : ubuntu-latest
104102
105103 # Define the sequence of job steps:
106104 steps :
107-
108- # Close the pull request:
109- - name : ' Close pull request'
110- run : gh pr close "$NUMBER" --comment "$BODY"
105+ # Close the pull request if the label is present, otherwise mark as successful:
106+ - name : " Close pull request or mark as successful"
107+ run : |
108+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: Project Conventions') }}" == "true" ]]; then
109+ gh pr close "$NUMBER" --comment "$BODY"
110+ else
111+ echo "Check for 'autoclose: Project Conventions' label passed."
112+ fi
111113 env :
112114 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
113115 GH_REPO : ${{ github.repository }}
@@ -127,22 +129,22 @@ jobs:
127129
128130 # Define a job which closes a pull request if a pull request is considered spam:
129131 spam :
130-
131132 # Define job name:
132- name : ' Check for spam label'
133-
134- # Only run this job if the pull request has a specific label:
135- if : " ${{ github.event.label.name == 'autoclose: Spam' }}"
133+ name : " Check for spam label"
136134
137135 # Define the type of virtual host machine:
138136 runs-on : ubuntu-latest
139137
140138 # Define the sequence of job steps:
141139 steps :
142-
143- # Close the pull request:
144- - name : ' Close pull request'
145- run : gh pr close "$NUMBER" --comment "$BODY"
140+ # Close the pull request if the label is present, otherwise mark as successful:
141+ - name : " Close pull request or mark as successful"
142+ run : |
143+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: Spam') }}" == "true" ]]; then
144+ gh pr close "$NUMBER" --comment "$BODY"
145+ else
146+ echo "Check for 'autoclose: Spam' label passed."
147+ fi
146148 env :
147149 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
148150 GH_REPO : ${{ github.repository }}
@@ -152,8 +154,9 @@ jobs:
152154
153155 Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
154156
155- # Lock pull request conversation:
156- - name : ' Lock conversation'
157+ # Lock pull request conversation if the label is present:
158+ - name : " Lock conversation"
159+ if : contains(github.event.pull_request.labels.*.name, 'autoclose: Spam')
157160 run : gh pr lock "$NUMBER" --reason spam
158161 env :
159162 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
@@ -162,21 +165,22 @@ jobs:
162165
163166 # Define a job which closes a pull request if a pull request is considered stale:
164167 stale :
165-
166168 # Define job name:
167- name : ' Check for stale label'
168-
169- # Only run this job if the pull request has a specific label:
170- if : " ${{ github.event.label.name == 'autoclose: Stale' }}"
169+ name : " Check for stale label"
171170
172171 # Define the type of virtual host machine:
173172 runs-on : ubuntu-latest
174173
175174 # Define the sequence of job steps:
176175 steps :
177- # Close the pull request:
178- - name : ' Close pull request'
179- run : gh pr close "$NUMBER" --comment "$BODY"
176+ # Close the pull request if the label is present, otherwise mark as successful:
177+ - name : " Close pull request or mark as successful"
178+ run : |
179+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: Stale') }}" == "true" ]]; then
180+ gh pr close "$NUMBER" --comment "$BODY"
181+ else
182+ echo "Check for 'autoclose: Stale' label passed."
183+ fi
180184 env :
181185 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
182186 GH_REPO : ${{ github.repository }}
@@ -188,22 +192,22 @@ jobs:
188192
189193 # Define a job which closes a pull request if a PR has an inappropriate Git history:
190194 git_history :
191-
192195 # Define job name:
193- name : ' Check for Git History label'
194-
195- # Only run this job if the pull request has a specific label:
196- if : " ${{ github.event.label.name == 'autoclose: Git History' }}"
196+ name : " Check for Git History label"
197197
198198 # Define the type of virtual host machine:
199199 runs-on : ubuntu-latest
200200
201201 # Define the sequence of job steps:
202202 steps :
203-
204- # Close the pull request:
205- - name : ' Close pull request'
206- run : gh pr close "$NUMBER" --comment "$BODY"
203+ # Close the pull request if the label is present, otherwise mark as successful:
204+ - name : " Close pull request or mark as successful"
205+ run : |
206+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: Git History') }}" == "true" ]]; then
207+ gh pr close "$NUMBER" --comment "$BODY"
208+ else
209+ echo "Check for 'autoclose: Git History' label passed."
210+ fi
207211 env :
208212 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
209213 GH_REPO : ${{ github.repository }}
@@ -224,27 +228,27 @@ jobs:
224228
225229 # Define a job which closes a pull request if proposed changes duplicate already included changes:
226230 already_resolved :
227-
228231 # Define job name:
229- name : ' Check for already resolved label'
230-
231- # Only run this job if the pull request has a specific label:
232- if : " ${{ github.event.label.name == 'autoclose: Already Resolved' }}"
232+ name : " Check for already resolved label"
233233
234234 # Define the type of virtual host machine:
235235 runs-on : ubuntu-latest
236236
237237 # Define the sequence of job steps:
238238 steps :
239-
240- # Close the pull request:
241- - name : ' Close pull request'
242- run : gh pr close "$NUMBER" --comment "$BODY"
239+ # Close the pull request if the label is present, otherwise mark as successful:
240+ - name : " Close pull request or mark as successful"
241+ run : |
242+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'autoclose: Already Resolved') }}" == "true" ]]; then
243+ gh pr close "$NUMBER" --comment "$BODY"
244+ else
245+ echo "Check for 'autoclose: Already Resolved' label passed."
246+ fi
243247 env :
244248 GH_TOKEN : ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
245249 GH_REPO : ${{ github.repository }}
246250 NUMBER : ${{ github.event.pull_request.number }}
247251 BODY : |
248252 Thank you for working on this pull request. However, we cannot accept your contribution as the issue this pull request seeks to resolve has already been addressed in a different pull request or commit.
249253
250- Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
254+ Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
0 commit comments