-
Notifications
You must be signed in to change notification settings - Fork 4
Replace CODEOWNERS with /merge command
#32
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
magicmark
wants to merge
20
commits into
main
Choose a base branch
from
replace-codeowners-with-merge-bot
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 all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8e9afc8
Replace CODEOWNERS with author-merge GitHub Action
magicmark aece13a
Simplify to /merge comment trigger only
magicmark 4ac87ba
Bump actions/checkout to v6
magicmark 2d3af10
Rename to merge.yml and clean up
magicmark 561ab6a
Use yq instead of grep -oP for parsing metadata.yml
magicmark 4bf612c
Harden merge workflow
magicmark 7ea531b
Clarify sponsor merges the initial GAP PR
magicmark 58c8995
Use exact match for /merge comment trigger
magicmark b8f0081
Remove concurrency guard — merge is idempotent
magicmark d3857bc
Simplify auth check to early-exit on failure
magicmark d47fe1c
Update CONTRIBUTING.md
magicmark 1278fb9
Merge file-fetch and directory-check into one step
magicmark 96e855a
Remove redundant metadata.yml existence check
magicmark 0a58804
Rewrite verification step with github-script
magicmark d973b2b
Revert "Rewrite verification step with github-script"
magicmark 32b5d60
Rewrite merge workflow with github-script
magicmark 72794b7
Extract verify-merge logic to dedicated script file
magicmark ba69f3e
Remove unused ts-check and jsdoc annotation
magicmark c0f5b42
Update verify-merge.js
magicmark 0fcd6d8
Fix gap directory mapping in verify-merge.js
magicmark 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Merge | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| merge: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.issue.pull_request && | ||
| github.event.comment.body == '/merge' | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - run: npm install js-yaml | ||
|
|
||
| - name: Verify actor is authorized | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| const verifyMerge = require('./scripts/verify-merge.js'); | ||
| await verifyMerge({ github, context }); | ||
|
|
||
| - name: Merge PR | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.issue.number }} | ||
| run: | | ||
| gh pr merge "$PR_NUMBER" --squash --auto | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
| const fs = require("fs"); | ||
| const yaml = require("js-yaml"); | ||
|
|
||
| module.exports = async ({ github, context }) => { | ||
| const actor = context.payload.comment.user.login; | ||
| const prNumber = context.issue.number; | ||
|
|
||
| const { data: files } = await github.rest.pulls.listFiles({ | ||
| ...context.repo, | ||
| pull_number: prNumber, | ||
| }); | ||
|
|
||
| const gapDirs = files | ||
| .map((f) => f.filename) | ||
| .map((p) => p.split("/").slice(0, 2).join("/")); | ||
|
|
||
| const gapsChanged = [...new Set(gapDirs)]; | ||
|
|
||
| if (gapsChanged.length !== 1 || !gapsChanged[0].match(/^gaps\/GAP-\d+$/)) { | ||
| throw new Error("You can only run /merge for PRs that touch exactly one GAP directory and nothing else."); | ||
| } | ||
|
|
||
| const metadata = yaml.load(fs.readFileSync(`${gapsChanged[0]}/metadata.yml`, "utf8")); | ||
| const authorizedMergers = new Set([ | ||
| ...metadata.authors.map(author => author.githubUsername.replace(/^@/, '')), | ||
| metadata.sponsor.replace(/^@/, ''), | ||
| ]); | ||
|
|
||
| if (!authorizedMergers.has(actor)) { | ||
| throw new Error(`${actor} is not authorized to merge ${gapsChanged[0]}.`); | ||
| } | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.