Skip to content

Commit

Permalink
ci: configured auto-approve & auto-merge for github actions
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic BIDON <[email protected]>
  • Loading branch information
fredbi committed Jan 25, 2024
1 parent 5872b5c commit 2000bf9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 9 deletions.
37 changes: 28 additions & 9 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
open-pull-requests-limit: 3 # <- default is 5
groups: # <- group all github actions updates in a single PR
development-dependencies:
dependency-type: development
patterns:
- '*'

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
open-pull-requests-limit: 3
groups:
development-dependencies:
dependency-type: development
patterns:
- "github.com/stretchr/testify"
go-openapi-dependencies:
dependency-type: production
patterns:
- "github.com/go-openapi/*"

36 changes: 36 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1

- name: Auto-approve dependabot PRs
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge dependabot PRs for development dependencies
if: contains(steps.metadata.outputs.dependency-group, 'development-dependencies')
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge dependabot PRs for go-openapi patches
if: contains(steps.metadata.outputs.dependency-group, 'go-openapi-dependencies') & steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 2000bf9

Please sign in to comment.