-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0896c04
commit 0b1a98b
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
name: Auto-Merge on LGTM Comment | ||
|
||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
|
||
permissions: | ||
contents: write # Required to merge the PR | ||
pull-requests: write # Required to update PRs | ||
|
||
jobs: | ||
auto_merge: | ||
name: Auto-Merge on LGTM | ||
if: ${{ startsWith(github.event.comment.body, 'lgtm') }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check if Comment is on a PR | ||
id: check-pr | ||
run: | | ||
if [[ "${{ github.event.issue.pull_request.url }}" == "" ]]; then | ||
echo "Not a pull request comment. Exiting." | ||
exit 1 | ||
fi | ||
- name: Merge Pull Request | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { context } = require("@actions/github"); | ||
const prNumber = context.payload.issue.number; | ||
const owner = context.payload.repository.owner.login; | ||
const repo = context.payload.repository.name; | ||
console.log(`Attempting to merge PR #${prNumber}`); | ||
await github.pulls.merge({ | ||
owner: owner, | ||
repo: repo, | ||
pull_number: prNumber, | ||
merge_method: "squash", // Change to "merge" or "rebase" if needed | ||
}); | ||
console.log(`Successfully merged PR #${prNumber}`); |