Skip to content

Commit d896eaf

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

File tree

4 files changed

+132
-0
lines changed

4 files changed

+132
-0
lines changed

.github/dependabot.yml

+13
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"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 pnpm
27+
uses: pnpm/action-setup@v4
28+
with:
29+
version: 9
30+
31+
- name: Set up Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: "lts/*"
35+
cache: pnpm
36+
37+
- name: Install dependencies
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Check for lockfile conflicts
41+
id: check-conflict
42+
run: |
43+
if git diff --name-only | grep 'pnpm-lock.yaml'; then
44+
echo "Lockfile conflict detected."
45+
echo "conflict=true" >> $GITHUB_ENV
46+
else
47+
echo "No lockfile conflict."
48+
echo "conflict=false" >> $GITHUB_ENV
49+
fi
50+
51+
- name: Resolve lockfile conflict
52+
if: env.conflict == 'true'
53+
run: |
54+
echo "Deleting pnpm-lock.yaml..."
55+
rm pnpm-lock.yaml
56+
echo "Reinstalling dependencies..."
57+
pnpm install
58+
59+
- name: Commit and push updated lockfile
60+
if: env.conflict == 'true'
61+
run: |
62+
git config --global user.name "dependabot-bot"
63+
git config --global user.email "[email protected]"
64+
git add pnpm-lock.yaml
65+
git commit -m "fix: Resolve pnpm-lock.yaml conflicts"
66+
git push origin ${{ github.event.pull_request.head.ref }}
67+
68+
auto-merge:
69+
needs: resolve-conflicts
70+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.job == 'resolve-conflicts' && github.event.pull_request.head.ref != 'null'
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Fetch Dependabot metadata
75+
id: metadata
76+
uses: dependabot/fetch-metadata@v1
77+
with:
78+
github-token: "${{ secrets.GITHUB_TOKEN }}"
79+
80+
- name: Enable auto-merge for Dependabot PRs
81+
run: gh pr merge --auto --merge "$PR_URL"
82+
env:
83+
PR_URL: ${{ github.event.pull_request.html_url }}
84+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/general-ci.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: General CI Workflow
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
test-and-build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up pnpm
17+
uses: pnpm/action-setup@v4
18+
with:
19+
run_install: false
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: "lts/*"
25+
cache: "pnpm"
26+
27+
- name: Install dependencies
28+
run: pnpm install --frozen-lockfile
29+
30+
- name: Run tests
31+
run: pnpm test
32+
33+
- name: Build the project
34+
run: pnpm build

package.json

+1
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)