Skip to content

Commit 6fef0a6

Browse files
committed
.github: Add a reset push label workflow
The current contribution flow requires a `push` label for a pull request to be merged. Only a user with write access can add the `push` label such as a maintainer. However, the `push` label is "sticky" and stays on the pull request from that point on. It was recently decided that the user adding the push label should always have to explicitly do so prior to merge. If a pull request is updated (by the PR author or, simply with a rebase), someone must reverify the contents and add the `push` label again. This means `push` labels will need to be added much more often to PRs. This prevents a "time-of-check-time-of-merge" torn state in the pull request contribution flow. Signed-off-by: Michael Kubacki <[email protected]>
1 parent 6c6d4d2 commit 6fef0a6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow removes the "push" label from a pull request when it is updated.
2+
#
3+
# A maintainer is expected to re-add the "push" label if the changes are ready to
4+
# be merged after the update. This is to ensure that any new changes prior to
5+
# merging have been reviewed by the maintainer.
6+
#
7+
# Copyright (c) Microsoft Corporation.
8+
# SPDX-License-Identifier: BSD-2-Clause-Patent
9+
#
10+
11+
name: Reset Push Label on PR Update
12+
13+
on:
14+
pull_request:
15+
types: [synchronize]
16+
17+
jobs:
18+
reset-push-label:
19+
name: Remove Push Label if Present
20+
if: github.repository_owner == 'tianocore' && github.triggering_actor.login != 'mergify[bot]'
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Generate Token
25+
id: app-token
26+
uses: actions/create-github-app-token@v2
27+
with:
28+
app-id: ${{ secrets.TIANOCORE_PR_AUTOMATION_APPLICATION_ID }}
29+
private-key: ${{ secrets.TIANOCORE_PR_AUTOMATION_APPLICATION_PRIVATE_KEY }}
30+
31+
- name: Reset push label
32+
uses: actions/github-script@v7
33+
with:
34+
github-token: ${{ steps.app-token.outputs.token }}
35+
script: |
36+
const labels = await github.rest.issues.listLabelsOnIssue({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
issue_number: context.issue.number
40+
});
41+
42+
const hasPushLabel = labels.data.some(label => label.name === 'push');
43+
44+
if (hasPushLabel) {
45+
await github.rest.issues.removeLabel({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
issue_number: context.issue.number,
49+
name: 'push'
50+
});
51+
console.log('Removed "push" label from PR #' + context.issue.number);
52+
} else {
53+
console.log('No "push" label found on PR #' + context.issue.number);
54+
}

0 commit comments

Comments
 (0)