Skip to content

⏫ Bot — Dependencies #4

⏫ Bot — Dependencies

⏫ Bot — Dependencies #4

# Groups minor and patch dependency updates into a single PR.
name: '⏫ Bot — Dependencies'
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
update-deps:
runs-on: ubuntu-latest
name: Update
steps:
- name: ➕ Actions - Checkout
uses: actions/checkout@v4
- name: ➕ Actions - Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: ➕ Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-linux-${{ hashFiles('package-lock.json') }}
restore-keys: npm-linux-
- name: 📦 Installing Dependencies
run: npm ci
- name: ⏫ Updating Dependencies
run: npm run update
- name: ⚙️ Configuring Git
run: |
git config --global user.name 'wellwelwel'
git config --global user.email '[email protected]'
git update-index --refresh > /dev/null 2>&1 || true
- name: 🔎 Checking for Changes
id: check_changes
run: |
if git diff-index --quiet HEAD --; then
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: 🔍 Checking if "jq" is installed
if: steps.check_changes.outputs.changes == 'true'
run: sudo apt-get install -y jq
- name: 🔍 Checking if Pull Request exists
if: steps.check_changes.outputs.changes == 'true'
id: check_pr
uses: octokit/[email protected]
with:
route: GET /repos/:owner/:repo/pulls
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
state: open
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔎 Checking if PR exists and is open
if: steps.check_changes.outputs.changes == 'true'
id: set_pr_exists
run: |
echo "pr_exists=false" >> $GITHUB_OUTPUT
for pr in $(jq -r '.[] | select(.title=="chore: update dependencies") | .number' <<< "${{ steps.check_pr.outputs.data }}"); do
echo "pr_exists=true" >> $GITHUB_OUTPUT
done
- name: 🚀 Commiting and Pushing Changes
if: steps.check_changes.outputs.changes == 'true'
run: |
git add .
git commit -m 'chore: update dependencies'
git push origin HEAD:deps --force
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: 🧙🏻 Creating Pull Request
if: steps.check_changes.outputs.changes == 'true' && steps.set_pr_exists.outputs.pr_exists == 'false'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
branch: deps
delete-branch: true
title: 'chore: update dependencies'
body: '- 🤖 Update project dependencies'
labels: |
dependencies