Skip to content

Commit 26e91fa

Browse files
ci: adapt auto-merge check for GitHub apps bots (leanprover-community#34980)
The steps in our build workflow which determine whether to act on the `auto-merge-after-CI` label are [failing](https://github.com/leanprover-community/mathlib4/actions/runs/21793023184/job/62877678664?pr=34967#step:8:11) when one of our new GitHub apps bots has applied the label, since the username no longer corresponds to a user. We fix that by whitelisting the bot usernames. ([Usernames must be unique across both bots and users](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app#registering-a-github-app) so it should be impossible for someone to pose as one of them.) Noticed in [#nightly-testing > Mathlib &leanprover-community#96;lake update&leanprover-community#96; failure @ 💬](https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/Mathlib.20.60lake.20update.60.20failure/near/572616935).
1 parent 019f853 commit 26e91fa

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/build_template.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,10 @@ jobs:
774774
echo "username=$USERNAME" >> "$GITHUB_OUTPUT"
775775
echo "Found label actor: $USERNAME"
776776
777-
- if: contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI')
777+
- if: >- # bot usernames will cause this step to error with "Could not resolve to a User..."
778+
contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI') &&
779+
steps.get-label-actor.outputs.username != 'mathlib-nolints' &&
780+
steps.get-label-actor.outputs.username != 'mathlib-update-dependencies'
778781
name: check team membership
779782
uses: tspascoal/get-user-teams-membership@57e9f42acd78f4d0f496b3be4368fc5f62696662 # v3.0.0
780783
id: actorTeams
@@ -784,11 +787,18 @@ jobs:
784787
username: ${{ steps.get-label-actor.outputs.username }}
785788
GITHUB_TOKEN: ${{ secrets.MATHLIB_REVIEWERS_TEAM_KEY }} # (Requires scope: `read:org`)
786789
787-
# The create-github-app-token README states that this token is masked and will not be logged accidentally.
788-
- if: ${{ contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI') && (contains(steps.actorTeams.outputs.teams, 'mathlib-maintainers') || contains(steps.actorTeams.outputs.teams, 'bot-users')) }}
790+
- if: >-
791+
contains(steps.PR.outputs.pr_labels, 'auto-merge-after-CI') &&
792+
(
793+
steps.get-label-actor.outputs.username == 'mathlib-nolints' ||
794+
steps.get-label-actor.outputs.username == 'mathlib-update-dependencies' ||
795+
contains(steps.actorTeams.outputs.teams, 'mathlib-maintainers') ||
796+
contains(steps.actorTeams.outputs.teams, 'bot-users')
797+
)
789798
name: If `auto-merge-after-CI` is present, add a `bors merge` comment.
790799
uses: GrantBirki/comment@608e41b19bc973020ec0e189ebfdae935d7fe0cc # v2.1.1
791800
with:
801+
# The create-github-app-token README states that this token is masked and will not be logged accidentally.
792802
token: ${{ steps.auto-merge-app-token.outputs.token }}
793803
issue-number: ${{ steps.PR.outputs.number }}
794804
body: |

0 commit comments

Comments
 (0)