Skip to content

Commit cdfae18

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

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-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,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 }}

.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)