Skip to content

Commit

Permalink
Merge pull request #299 from domainr/dependabot-auto-approve
Browse files Browse the repository at this point in the history
GH Actions workflow updates
  • Loading branch information
case-fastly committed Sep 21, 2023
2 parents dc30bfd + 91db516 commit da9b65b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 38 deletions.
49 changes: 31 additions & 18 deletions .github/workflows/automerge.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
name: Merge
name: Approve & Merge

on:
pull_request_review:
types:
- submitted
pull_request

permissions:
contents: write
pull-requests: write

jobs:
approve:
runs-on: ubuntu-22.04
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
merge:
name: Merge pull request
if: |
github.event.review.state == 'approved' &&
github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-22.04
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Merge
uses: actions/github-script@v6.4.1
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
with:
github-token: ${{ secrets.DOMAINRBOT_RW_GITHUB_ACCESS_TOKEN }}
script: |
github.pulls.merge({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.pull_request.number,
merge_method: 'merge'
})
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: ${{contains(steps.metadata.outputs.dependency-names, 'zonedb') && steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
20 changes: 0 additions & 20 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,3 @@ jobs:

- name: Verify repo is unchanged
run: git diff --exit-code HEAD

review:
name: Review pull request
needs: test
if: |
github.event.pull_request.user.login == 'dependabot[bot]' &&
contains(github.head_ref, 'dependabot/go_modules/github.com/zonedb/zonedb')
runs-on: ubuntu-latest
steps:
- name: Approve pull request
uses: actions/github-script@v6.4.1
with:
github-token: ${{ secrets.DOMAINRBOT_RW_GITHUB_ACCESS_TOKEN }}
script: |
github.pulls.createReview({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.pull_request.number,
event: 'APPROVE'
})

0 comments on commit da9b65b

Please sign in to comment.