You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 481d4e3
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .github/workflows/close-on-invalid-label.yaml
+72-1Lines changed: 72 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,12 @@ name: Close issue/PR on adding invalid label
2
2
3
3
# Closes public issues and PRs when the invalid label is added.
4
4
# Re-closes invalid PRs that someone without write access reopens.
5
+
# Reopens PRs closed as invalid when maintainers add the skip-spammy-check label.
5
6
6
7
on:
7
8
issues:
8
9
types: [labeled]
9
-
# pull_request_target lets the workflow close forked PRs when they're labeled invalid or reopened.
10
+
# pull_request_target lets the workflow close or reopen forked PRs when they're labeled or reopened.
10
11
pull_request_target:
11
12
types: [labeled, reopened]
12
13
@@ -71,3 +72,73 @@ jobs:
71
72
exit 0
72
73
fi
73
74
gh pr close "$PR_URL" --comment 'This pull request is labeled `invalid`, so only maintainers can reopen it. If you think this is incorrect, please mention this in a corresponding issue.'
75
+
76
+
# Maintainers add skip-spammy-check to recover a PR that automated checks closed as invalid.
// GitHub refuses to reopen a PR after its head or base branch was deleted or force-pushed.
117
+
core.warning(`Could not reopen the pull request: ${error.message}`)
118
+
await github.rest.issues.createComment({
119
+
owner,
120
+
repo,
121
+
issue_number: pull_number,
122
+
body: 'I could not reopen this pull request automatically, most likely because its head or base branch was deleted or force-pushed after it was closed. Restore the branch, then remove and re-add the `skip-spammy-check` label to retry automatic reopening and removal of the `invalid` label.',
123
+
})
124
+
return
125
+
}
126
+
127
+
try {
128
+
await github.rest.issues.removeLabel({
129
+
owner,
130
+
repo,
131
+
issue_number: pull_number,
132
+
name: 'invalid',
133
+
})
134
+
} catch (error) {
135
+
// A maintainer or an earlier run may have removed the label already.
136
+
if (error.status !== 404) throw error
137
+
}
138
+
139
+
await github.rest.issues.createComment({
140
+
owner,
141
+
repo,
142
+
issue_number: pull_number,
143
+
body: 'The `skip-spammy-check` label was added, so I removed the `invalid` label and reopened this pull request. The spammy pull request check skips it while the label is applied.',
0 commit comments