Skip to content

Commit

Permalink
feat(ci): add a workflow to auto-merge a Dependabot PR (#183)
Browse files Browse the repository at this point in the history
* chore(ci): rename check commit workflow

* feat(ci): add a workflow to auto-merge dependabot PRs
  • Loading branch information
coffeebeats authored Jan 1, 2024
1 parent cedff20 commit 2ac31ed
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/check-commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "🤖 Check: 'gdenv'"
name: "🤖 Check: Commit"

on:
pull_request:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/merge-dependabot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "🤖 Merge: Dependabot PR"

on:
pull_request:
branches:
- main

permissions:
contents: write

env:
# This is required to use the 'gh' CLI in actions.
GH_TOKEN: ${{ github.token }}

jobs:
# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request.
dependabot:
if: |
github.event_name == 'pull_request' &&
github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 1

steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
if: |
contains(steps.metadata.outputs.dependency-names, 'my-dependency') &&
steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --merge "${{ github.event.pull_request.html_url }}"

0 comments on commit 2ac31ed

Please sign in to comment.