Skip to content

Commit

Permalink
update approve_and_merge.yml (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktr0731 authored Mar 4, 2022
1 parent 8255f49 commit d52df63
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions .github/workflows/approve_and_merge.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
name: "Auto approve Pull Requests and enable auto-merge"
on:
pull_request_target
permissions:
pull-requests: write
jobs:
worker:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: automerge
uses: actions/[email protected]
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GH_TOKEN }}"
script: |
await github.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
event: 'APPROVE'
})
const res = await github.graphql(`query {
repository(owner: "${context.repo.owner}", name: "${context.repo.repo}") {
pullRequest(number: ${context.issue.number}) {
id
}
}
}`)
await github.graphql(`mutation {
enablePullRequestAutoMerge(input: { pullRequestId: "${res.repository.pullRequest.id}", mergeMethod: SQUASH }) {
clientMutationId
}
}`)
github-token: ${{secrets.GH_TOKEN}}
- name: Approve
run: gh pr review --approve $PR_URL
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
- name: Enable auto-merge
run: gh pr merge --auto --squash $PR_URL
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}

0 comments on commit d52df63

Please sign in to comment.