Skip to content

Commit

Permalink
add Github Actions Worflow to automerge dependabot PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
kik-kik committed Mar 1, 2024
1 parent 997788b commit bf127e6
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/dependabotautomerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# source: https://localheinz.com/articles/2020/06/15/merging-pull-requests-with-github-actions/
# and: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow
name: "Merge - Dependabot PR"

on:
pull_request:
branches:
- 'dependabot/**'

check_run:
types: [completed]

jobs:
merge:
name: "Merge"

runs-on: "ubuntu-latest"

if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' &&
github.actor == 'dependabot[bot]'
# steps:
# - name: "Approve pull request"
# uses: "actions/github-script@v7"
# with:
# github-token: "${{ secrets.GITHUB_TOKEN }}"
# script: |
# const pullRequest = context.payload.workflow_run.pull_requests[0]
# const repository = context.repo

# await github.rest.pulls.createReview({
# event: "APPROVE",
# owner: repository.owner,
# repo: repository.repo,
# pull_number: pullRequest.number,
# })

- name: "Merge pull request"
uses: "actions/github-script@v7"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const pullRequest = context.payload.workflow_run.pull_requests[0]
const repository = context.repo
await github.rest.pulls.merge({
merge_method: "merge",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})

0 comments on commit bf127e6

Please sign in to comment.