Skip to content

Configure Dependabot for dependency updates (#16) #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "deps"
open-pull-requests-limit: 5
labels:
- "dependencies"
allow:
- dependency-type: "all"
79 changes: 79 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Dependabot Auto Merge and Resolve Lockfile Conflicts

on:
pull_request:
branches:
- master
types:
- opened
- synchronize

permissions:
contents: write
pull-requests: write

jobs:
resolve-conflicts:
if: github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: pnpm

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Check for lockfile conflicts
id: check-conflict
run: |
if git diff --name-only | grep 'pnpm-lock.yaml'; then
echo "Lockfile conflict detected."
echo "conflict=true" >> $GITHUB_ENV
else
echo "No lockfile conflict."
echo "conflict=false" >> $GITHUB_ENV
fi

- name: Resolve lockfile conflict
if: env.conflict == 'true'
run: |
echo "Deleting pnpm-lock.yaml..."
rm pnpm-lock.yaml
echo "Reinstalling dependencies..."
pnpm install

- name: Commit and push updated lockfile
if: env.conflict == 'true'
run: |
git config --global user.name "dependabot-bot"
git config --global user.email "[email protected]"
git add pnpm-lock.yaml
git commit -m "fix: Resolve pnpm-lock.yaml conflicts"
git push origin ${{ github.event.pull_request.head.ref }}

auto-merge:
needs: resolve-conflicts
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.job == 'resolve-conflicts' && github.event.pull_request.head.ref != 'null'
runs-on: ubuntu-latest

steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/general-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: General CI Workflow

on:
pull_request:
branches:
- master

jobs:
test-and-build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test

- name: Build the project
run: pnpm build
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "fastify-swc-typescript-server",
"packageManager": "[email protected]",
"version": "1.0.0",
"description": "A Fastify server leveraging SWC for transpilation and Jest for testing.",
"main": "dist/index.js",
Expand Down