Skip to content

Commit 269d5d8

Browse files
committed
feat: add Dependabot automation for weekly dependency updates
Configure Dependabot for npm and github-actions ecosystems with: - Weekly schedule (Monday 09:55 for actions, 10:00 for npm) - Grouped updates to minimize PR noise - `increase-if-necessary` strategy to keep package.json ranges clean Add workflow to handle Dependabot PRs: - Rebuild TypeScript dist for npm updates (javascript label) - Auto-approve and merge via GitHub App token Update release workflow to ignore .github/** changes so action updates don't trigger unnecessary releases.
1 parent 91feb7e commit 269d5d8

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

.github/dependabot.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: "09:55"
9+
timezone: Europe/Dublin
10+
open-pull-requests-limit: 1
11+
groups:
12+
github-actions:
13+
patterns:
14+
- "*"
15+
16+
- package-ecosystem: npm
17+
directory: /
18+
schedule:
19+
interval: weekly
20+
day: monday
21+
time: "10:00"
22+
timezone: Europe/Dublin
23+
versioning-strategy: increase-if-necessary
24+
open-pull-requests-limit: 1
25+
groups:
26+
npm-dependencies:
27+
patterns:
28+
- "*"

.github/workflows/dependabot.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: dependabot
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
repository-projects: read
12+
13+
jobs:
14+
build:
15+
name: 🔧 Rebuild TypeScript
16+
if: github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'javascript')
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Generate token
21+
id: generate
22+
uses: actions/create-github-app-token@v2
23+
with:
24+
app-id: ${{ vars.DEPENDENCY_AUTOMATION_APP_ID }}
25+
private-key: ${{ secrets.DEPENDENCY_AUTOMATION_APP_KEY }}
26+
27+
- uses: actions/checkout@main
28+
with:
29+
ref: ${{ github.head_ref }}
30+
token: ${{ steps.generate.outputs.token }}
31+
32+
- name: Format & rebuild
33+
run: |
34+
npm ci
35+
npm run format
36+
npm run build
37+
38+
- name: Commit changes
39+
run: |
40+
git config --local user.name "github-actions[bot]"
41+
git config --local user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
42+
git add dist/ src/
43+
git diff --staged --quiet || git commit -m "chore: rebuild dist"
44+
git push
45+
46+
# Github Action bump PRs skip the TypeScript rebuild since they don't have the 'javascript' label
47+
# hence the 'always()' condition - to ensure this job runs for those PRs, too.
48+
auto-merge:
49+
name: 🤖 Approve and auto-merge
50+
needs: build
51+
if: always() && github.actor == 'dependabot[bot]' && !contains(needs.*.result, 'failure')
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- name: Generate token
56+
id: generate
57+
uses: actions/create-github-app-token@v2
58+
with:
59+
app-id: ${{ vars.DEPENDENCY_AUTOMATION_APP_ID }}
60+
private-key: ${{ secrets.DEPENDENCY_AUTOMATION_APP_KEY }}
61+
62+
- name: Approve and auto-merge
63+
env:
64+
GITHUB_TOKEN: ${{ steps.generate.outputs.token }}
65+
run: |
66+
gh pr review "${{ github.event.pull_request.html_url }}" --approve
67+
gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
paths-ignore:
88
- "**.md"
9+
- ".github/**"
910

1011
concurrency:
1112
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

0 commit comments

Comments
 (0)