-
-
Notifications
You must be signed in to change notification settings - Fork 9
Automate bot PR maintenance end-to-end #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tpvasconcelos
wants to merge
16
commits into
main
Choose a base branch
from
automate-bot-pr-maintenance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0e2e719
Automate bot PR maintenance: weekly grouped updates, skip-news labeli…
tpvasconcelos 43fbf03
Add changelog entry for bot PR automation
tpvasconcelos c44e18d
Merge branch 'main' into automate-bot-pr-maintenance
tpvasconcelos a052353
Merge branch 'main' into automate-bot-pr-maintenance
tpvasconcelos d52675d
Rework bot PR automation: commit changelog entries directly to bot PRs
tpvasconcelos 916d9d5
Rewrite add_changelog_entry.py using markdown-it-py source maps
tpvasconcelos 8cf5e35
Never execute code from PR branches in the bot PR automation
tpvasconcelos a15c283
Merge remote-tracking branch 'origin/main' into bot-prs-security-hard…
tpvasconcelos 082203e
Require the AUTO_MERGE_PAT secret instead of falling back to GITHUB_T…
tpvasconcelos 5f05a6f
Add bot changelog entries to a sorted '### Dependencies' subsection
tpvasconcelos bf5c21e
Rename the bot PR workflow to bot-pr-automation.yml
tpvasconcelos 436a5e2
Heal bot PRs that fall behind main, not just conflicted ones
tpvasconcelos 8610dcc
Add an aggregate 'All CI checks passed' job for branch protection
tpvasconcelos 32aae22
Replace the aggregate CI job with a self-maintaining all-checks gate
tpvasconcelos a071c1e
Adopt the ecosystem-standard CI gate job instead of an API-polling gate
tpvasconcelos 97baa13
Keep the required status checks as config-as-code in the repository
tpvasconcelos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Automation for PRs opened by trusted bots (dependabot and pre-commit.ci). | ||
| # | ||
| # For every bot PR, this workflow: | ||
| # 1. Adds the `skip news` label, which exempts the PR from the changelog | ||
| # check (dependabot PRs already get it via .github/dependabot.yml). | ||
| # The corresponding changelog entries are added in bulk at release | ||
| # time with the help of ./cicd_utils/find-unmentioned-prs.sh | ||
| # 2. Enables GitHub's native auto-merge (squash). The PR will then merge | ||
| # automatically as soon as the branch protection requirements are met | ||
| # (i.e., an approving review plus all required status checks passing). | ||
| # | ||
| # The only human action left is the review itself. | ||
| # | ||
| # Note: If auto-merge is enabled with the default GITHUB_TOKEN, the resulting | ||
| # merge commit will not trigger other workflows (e.g., the CI run on main or | ||
| # the TestPyPI publish). To get those post-merge runs, create a fine-grained | ||
| # PAT with contents:write and pull-requests:write scoped to this repository | ||
| # and store it as the AUTO_MERGE_PAT secret. This workflow falls back to | ||
| # GITHUB_TOKEN when the secret is not set. | ||
| # | ||
| # Security: this workflow runs on pull_request_target but never checks out | ||
| # or executes code from the PR branch. | ||
| # | ||
| name: Bot PRs | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [ opened, reopened ] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| automate: | ||
| name: Label and enable auto-merge | ||
| if: >- | ||
| github.event.pull_request.user.login == 'dependabot[bot]' || | ||
| github.event.pull_request.user.login == 'pre-commit-ci[bot]' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 2 | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Add 'skip news' label | ||
| run: gh pr edit "$PR_URL" --add-label 'skip news' | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Enable auto-merge (squash) | ||
| run: gh pr merge --auto --squash "$PR_URL" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GH_TOKEN: ${{ secrets.AUTO_MERGE_PAT || secrets.GITHUB_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this job is triggered by a Dependabot PR, it matches this condition, but GitHub treats Dependabot-triggered
pull_request_targetruns whose PR user isdependabot[bot]as read-only and without Actions secrets (see GitHub's Dependabot-on-Actions restrictions: https://docs.github.com/en/code-security/reference/supply-chain-security/dependabot-on-actions#restrictions-when-dependabot-triggers-events). That meansAUTO_MERGE_PATis unavailable and the fallbackGITHUB_TOKENcannot run the latergh pr edit/gh pr merge --autowrites, so weekly Dependabot PRs will fail this workflow instead of getting auto-merge enabled.Useful? React with 👍 / 👎.