Skip to content

feat(ci): auto-update package-lock file #1

feat(ci): auto-update package-lock file

feat(ci): auto-update package-lock file #1

name: Auto Update package-lock.json
on:
pull_request:
paths:
- 'package.json'
jobs:
update-package-lock:
runs-on: ubuntu-latest
steps:
- name: Fail if branch is main
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo "This workflow should not be triggered with workflow_dispatch on main"
exit 1
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Install npm dependencies
run: npm install
- name: Check for Changes
run: |
if ! git diff --quiet -- package-lock.json; then
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
fi
- name: Commit package-lock.json changes
if: env.CHANGES_DETECTED == 'true'
uses: EndBug/add-and-commit@v9
with:
add: package-lock.json
default_author: github_actions
message: "🤖 update package-lock.json"