Skip to content

Commit 1eafd22

Browse files
Configure Dependabot for dependency updates (#16) (#17)
* Configure Dependabot for dependency updates (#16) * Add packageManager to package.json
1 parent 7c72aac commit 1eafd22

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
commit-message:
8+
prefix: "deps"
9+
open-pull-requests-limit: 5
10+
labels:
11+
- "dependencies"
12+
allow:
13+
- dependency-type: "all"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Dependabot Auto Merge and Resolve Lockfile Conflicts
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types:
8+
- opened
9+
- synchronize
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
resolve-conflicts:
17+
if: github.event.pull_request.user.login == 'dependabot[bot]'
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.pull_request.head.ref }}
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "lts/*"
30+
cache: pnpm
31+
32+
- name: Install pnpm
33+
uses: pnpm/action-setup@v4
34+
35+
- name: Check for lockfile conflicts
36+
id: check-conflict
37+
run: |
38+
if git diff --name-only | grep 'pnpm-lock.yaml'; then
39+
echo "Lockfile conflict detected."
40+
echo "conflict=true" >> $GITHUB_ENV
41+
else
42+
echo "No lockfile conflict."
43+
echo "conflict=false" >> $GITHUB_ENV
44+
fi
45+
46+
- name: Resolve lockfile conflict
47+
if: env.conflict == 'true'
48+
run: |
49+
echo "Deleting pnpm-lock.yaml..."
50+
rm pnpm-lock.yaml
51+
echo "Reinstalling dependencies..."
52+
pnpm install
53+
54+
- name: Commit and push updated lockfile
55+
if: env.conflict == 'true'
56+
run: |
57+
git config --global user.name "dependabot-bot"
58+
git config --global user.email "[email protected]"
59+
git add pnpm-lock.yaml
60+
git commit -m "fix: Resolve pnpm-lock.yaml conflicts"
61+
git push origin ${{ github.event.pull_request.head.ref }}
62+
63+
auto-merge:
64+
needs: resolve-conflicts
65+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.job == 'resolve-conflicts' && github.event.pull_request.head.ref != 'null'
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Fetch Dependabot metadata
70+
id: metadata
71+
uses: dependabot/fetch-metadata@v1
72+
with:
73+
github-token: "${{ secrets.GITHUB_TOKEN }}"
74+
75+
- name: Enable auto-merge for Dependabot PRs
76+
run: gh pr merge --auto --merge "$PR_URL"
77+
env:
78+
PR_URL: ${{ github.event.pull_request.html_url }}
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/general-ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Dependabot Auto Merge and Resolve Lockfile Conflicts
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types:
8+
- opened
9+
- synchronize
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
resolve-conflicts:
17+
if: github.event.pull_request.user.login == 'dependabot[bot]'
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.pull_request.head.ref }}
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "lts/*"
30+
cache: pnpm
31+
32+
- name: Install pnpm using action
33+
uses: pnpm/action-setup@v4
34+
35+
- name: Fallback install pnpm using npm
36+
if: failure()
37+
run: npm install -g pnpm
38+
39+
- name: Check for lockfile conflicts
40+
id: check-conflict
41+
run: |
42+
if git diff --name-only | grep 'pnpm-lock.yaml'; then
43+
echo "Lockfile conflict detected."
44+
echo "conflict=true" >> $GITHUB_ENV
45+
else
46+
echo "No lockfile conflict."
47+
echo "conflict=false" >> $GITHUB_ENV
48+
fi
49+
50+
- name: Resolve lockfile conflict
51+
if: env.conflict == 'true'
52+
run: |
53+
echo "Deleting pnpm-lock.yaml..."
54+
rm pnpm-lock.yaml
55+
echo "Reinstalling dependencies..."
56+
pnpm install
57+
58+
- name: Commit and push updated lockfile
59+
if: env.conflict == 'true'
60+
run: |
61+
git config --global user.name "dependabot-bot"
62+
git config --global user.email "[email protected]"
63+
git add pnpm-lock.yaml
64+
git commit -m "fix: Resolve pnpm-lock.yaml conflicts"
65+
git push origin ${{ github.event.pull_request.head.ref }}
66+
67+
auto-merge:
68+
needs: resolve-conflicts
69+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.job == 'resolve-conflicts' && github.event.pull_request.head.ref != 'null'
70+
runs-on: ubuntu-latest
71+
72+
steps:
73+
- name: Fetch Dependabot metadata
74+
id: metadata
75+
uses: dependabot/fetch-metadata@v1
76+
with:
77+
github-token: "${{ secrets.GITHUB_TOKEN }}"
78+
79+
- name: Enable auto-merge for Dependabot PRs
80+
run: gh pr merge --auto --merge "$PR_URL"
81+
env:
82+
PR_URL: ${{ github.event.pull_request.html_url }}
83+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "fastify-swc-typescript-server",
3+
"packageManager": "[email protected]",
34
"version": "1.0.0",
45
"description": "A Fastify server leveraging SWC for transpilation and Jest for testing.",
56
"main": "dist/index.js",

0 commit comments

Comments
 (0)