Auto Update Dependencies #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Update Dependencies | |
on: | |
schedule: | |
- cron: "0 0 * * 0" # Run weekly on Sundays at midnight | |
workflow_dispatch: # Allows manual trigger from GitHub UI | |
jobs: | |
update-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "22" # Specify the Node.js version you use | |
- name: Set up Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: "latest" # Specify the Bun version you want | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: "latest" # Specify the pnpm version you want | |
- name: Install npm-check-updates | |
run: npm install -g npm-check-updates | |
- name: Install Bun dependencies | |
run: bun install | |
- name: Get outdated dependencies | |
uses: mathiasvr/[email protected] | |
continue-on-error: true | |
id: outdated | |
with: | |
run: | | |
ncu --format repo | head -n -2 | tail -n +3 > ncu-output.txt | |
echo "| Package | Current Version | Latest Version | URL |" > ncu-output.md | |
echo "| --- | --- | --- | --- |" >> ncu-output.md | |
# Process the `ncu` output and format it into Markdown | |
awk ' | |
{ | |
gsub(/\^/, "", $2); | |
gsub(/\^/, "", $4); | |
print "| " $1 " | " $2 " | " $4 " | " $5 " |" | |
}' ncu-output.txt >> ncu-output.md | |
cat ncu-output.md | |
rm ncu-output.txt ncu-output.md | |
- name: Update package.json | |
run: ncu -u | |
- name: Update Bun dependencies | |
uses: mathiasvr/[email protected] | |
id: updates | |
with: | |
run: bun install | head -n -2 | |
- name: Update npm dependencies | |
run: npm install --package-lock-only | |
- name: Update pnpm dependencies | |
run: pnpm install --no-frozen-lockfile --lockfile-only | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
title: "Update dependencies" | |
body: | | |
This PR updates dependencies to their latest versions. | |
${{ steps.outdated.outputs.stdout }} | |
branch: "update-deps" | |
commit-message: | | |
chore(deps): update dependencies | |
${{ steps.updates.outputs.stdout }} | |
base: "main" # Specify your default branch |