Skip to content

Commit 03dc1ba

Browse files
authored
ci: add Dependabot and automated dependency updates [ENG-11704] (#262)
* ci(deps): add Dependabot and automated dependency updates - Add Dependabot config for npm and GitHub Actions - Add auto-merge workflow for Dependabot PRs (minor/patch only) - Add scheduled Nix flake update workflow with auto-merge * ci(nix): use setup-nix action for flake update workflow * ci: pin GitHub Actions with pinact
1 parent 6c38298 commit 03dc1ba

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

.github/dependabot.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: 2
2+
updates:
3+
# npm dependencies (pnpm compatible)
4+
- package-ecosystem: npm
5+
directory: /
6+
schedule:
7+
interval: weekly
8+
day: monday
9+
time: '09:00'
10+
timezone: Europe/London
11+
open-pull-requests-limit: 10
12+
commit-message:
13+
prefix: 'chore(deps)'
14+
labels:
15+
- dependencies
16+
groups:
17+
# Group minor and patch updates together
18+
minor-and-patch:
19+
patterns:
20+
- '*'
21+
update-types:
22+
- minor
23+
- patch
24+
# Ignore major updates for stability (review manually)
25+
ignore:
26+
- dependency-name: '*'
27+
update-types:
28+
- version-update:semver-major
29+
30+
# GitHub Actions dependencies
31+
- package-ecosystem: github-actions
32+
directory: /
33+
schedule:
34+
interval: weekly
35+
day: monday
36+
time: '09:00'
37+
timezone: Europe/London
38+
open-pull-requests-limit: 5
39+
commit-message:
40+
prefix: 'ci(deps)'
41+
labels:
42+
- dependencies
43+
- ci
44+
groups:
45+
actions:
46+
patterns:
47+
- '*'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Dependabot auto-merge
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
dependabot-auto-merge:
16+
runs-on: ubuntu-latest
17+
if: github.actor == 'dependabot[bot]'
18+
steps:
19+
- name: Fetch Dependabot metadata
20+
id: metadata
21+
uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b # v2.4.0
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Wait for CI to pass
26+
uses: lewagon/wait-on-check-action@ccfb013c15c8afb7bf2b7c028fb74dc5a068cccc # v1.3.4
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
running-workflow-name: Dependabot auto-merge
30+
repo-token: ${{ secrets.GITHUB_TOKEN }}
31+
wait-interval: 30
32+
33+
# Enable auto-merge for minor/patch updates
34+
# GitHub will wait for required checks and 3-day delay before merging
35+
- name: Enable auto-merge for minor/patch updates
36+
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
37+
run: gh pr merge --auto --squash "$PR_URL"
38+
env:
39+
PR_URL: ${{ github.event.pull_request.html_url }}
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Add comment about merge delay
43+
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
44+
run: |
45+
gh pr comment "$PR_URL" --body "🤖 Auto-merge enabled. This PR will be merged automatically after CI passes and the 3-day waiting period (configured in branch protection rules)."
46+
env:
47+
PR_URL: ${{ github.event.pull_request.html_url }}
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 'Scheduled: Nix flake update'
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 09:00 UTC (same as Dependabot)
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
update-flake:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
19+
20+
- name: Setup Nix
21+
uses: ./.github/actions/setup-nix
22+
23+
- name: Update flake.lock
24+
run: nix flake update
25+
26+
- name: Check if flake.lock changed
27+
id: check-changes
28+
run: |
29+
if git diff --quiet flake.lock; then
30+
echo "changed=false" >> $GITHUB_OUTPUT
31+
else
32+
echo "changed=true" >> $GITHUB_OUTPUT
33+
fi
34+
35+
- name: Create Pull Request
36+
id: create-pr
37+
if: steps.check-changes.outputs.changed == 'true'
38+
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
commit-message: 'chore(deps): update nix flake inputs'
42+
title: 'chore(deps): update nix flake inputs'
43+
body: |
44+
## Summary
45+
- Automated update of Nix flake inputs (`nixpkgs`, `flake-parts`)
46+
47+
## Test plan
48+
- [ ] `nix flake check` passes in CI
49+
- [ ] Development shell works correctly
50+
51+
---
52+
🤖 This PR was automatically created by the scheduled Nix flake update workflow.
53+
branch: chore/nix-flake-update
54+
labels: |
55+
dependencies
56+
nix
57+
delete-branch: true
58+
59+
- name: Enable auto-merge
60+
if: steps.create-pr.outputs.pull-request-number
61+
run: gh pr merge --auto --squash "${{ steps.create-pr.outputs.pull-request-url }}"
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)