Skip to content

Commit

Permalink
Create lgtm.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank77maruti authored Jan 2, 2025
1 parent 0896c04 commit 0b1a98b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/lgtm.yml
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}`);

0 comments on commit 0b1a98b

Please sign in to comment.