Skip to content
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

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
43 changes: 43 additions & 0 deletions .github/workflows/update-lockfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"