Skip to content

Commit c877230

Browse files
committed
ci(dependencies): automate dependencies updates
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
1 parent a05020e commit c877230

File tree

2 files changed

+97
-9
lines changed

2 files changed

+97
-9
lines changed

.github/dependabot.yaml

+54-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,56 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "gomod"
4-
directory: "/"
5-
schedule:
6-
interval: "monthly"
7-
open-pull-requests-limit: 10
8-
- package-ecosystem: "github-actions"
9-
directory: "/"
10-
schedule:
11-
interval: "weekly"
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "friday"
8+
open-pull-requests-limit: 2 # <- default is 5
9+
groups: # <- group all github actions updates in a single PR
10+
# 1. development-dependencies are auto-merged
11+
development-dependencies:
12+
patterns:
13+
- '*'
14+
15+
- package-ecosystem: "gomod"
16+
# We define 4 groups of dependencies to regroup update pull requests:
17+
# - development (e.g. test dependencies)
18+
# - go-openapi updates
19+
# - golang.org (e.g. golang.org/x/... packages)
20+
# - other dependencies (direct or indirect)
21+
#
22+
# * All groups are checked once a week and each produce at most 1 PR.
23+
# * All dependabot PRs are auto-approved
24+
#
25+
# Auto-merging policy, when requirements are met:
26+
# 1. development-dependencies are auto-merged
27+
# 2. golang.org-dependencies are auto-merged
28+
# 3. go-openapi patch updates are auto-merged. Minor/major version updates require a manual merge.
29+
# 4. other dependencies require a manual merge
30+
directory: "/"
31+
schedule:
32+
interval: "weekly"
33+
day: "friday"
34+
open-pull-requests-limit: 4
35+
groups:
36+
development-dependencies:
37+
dependency-type: development
38+
patterns:
39+
- "github.com/stretchr/testify"
40+
41+
golang.org-dependencies:
42+
dependency-type: production
43+
patterns:
44+
- "golang.org/*"
45+
46+
go-openapi-dependencies:
47+
dependency-type: production
48+
patterns:
49+
- "github.com/go-openapi/*"
50+
51+
other-dependencies:
52+
dependency-type: production
53+
exclude-patterns:
54+
- "github.com/go-openapi/*"
55+
- "github.com/stretchr/testify"
56+
- "golang.org/*"

.github/workflows/auto-merge.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: github.actor == 'dependabot[bot]'
12+
steps:
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@v1
16+
17+
- name: Auto-approve all dependabot PRs
18+
run: gh pr review --approve "$PR_URL"
19+
env:
20+
PR_URL: ${{github.event.pull_request.html_url}}
21+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
23+
- name: Auto-merge dependabot PRs for development dependencies
24+
if: contains(steps.metadata.outputs.dependency-group, 'development-dependencies')
25+
run: gh pr merge --auto --rebase "$PR_URL"
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
28+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
29+
30+
- name: Auto-merge dependabot PRs for go-openapi patches
31+
if: contains(steps.metadata.outputs.dependency-group, 'go-openapi-dependencies') && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch')
32+
run: gh pr merge --auto --rebase "$PR_URL"
33+
env:
34+
PR_URL: ${{github.event.pull_request.html_url}}
35+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
36+
37+
- name: Auto-merge dependabot PRs for golang.org updates
38+
if: contains(steps.metadata.outputs.dependency-group, 'golang.org-dependencies')
39+
run: gh pr merge --auto --rebase "$PR_URL"
40+
env:
41+
PR_URL: ${{github.event.pull_request.html_url}}
42+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
43+

0 commit comments

Comments
 (0)