-
Notifications
You must be signed in to change notification settings - Fork 5
chore: add workflow to sync package-lock.json when it drifts from pac… #421
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
base: main
Are you sure you want to change the base?
Changes from all commits
de374d2
894f6ab
893bea7
fbba6b9
6e3f8df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,14 @@ jobs: | |
| format-check: | ||
| name: Format Check | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: ${{ github.head_ref || github.ref }} | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | ||
|
|
@@ -24,5 +28,16 @@ jobs: | |
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| - name: Run format check | ||
| run: npm run format:check | ||
| - name: Apply formatting | ||
| run: npm run format:write | ||
|
|
||
| - name: Commit fixes if needed | ||
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add -u | ||
| if ! git diff --cached --quiet; then | ||
| git commit -m "chore: apply formatting and sync lockfile" | ||
| git push | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auto-push on This workflow triggers on Options:
|
||
| fi | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,5 +18,5 @@ jobs: | |||||||||||||
| with: | ||||||||||||||
| node-version-file: '.node-version' | ||||||||||||||
| cache: 'npm' | ||||||||||||||
| - run: npm ci | ||||||||||||||
| - run: npm i | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With Now that this PR ships a freshly-synced lockfile and a
Suggested change
|
||||||||||||||
| - run: npm run lint:required | ||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||
| name: Sync Lock File | ||||||||||||
|
|
||||||||||||
| on: | ||||||||||||
| push: | ||||||||||||
| branches: | ||||||||||||
| - main | ||||||||||||
| paths: | ||||||||||||
| - 'package.json' | ||||||||||||
| schedule: | ||||||||||||
| - cron: '0 9 * * 1' # Run every Monday at 09:00 UTC | ||||||||||||
| workflow_dispatch: | ||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
| sync-lockfile: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| permissions: | ||||||||||||
| contents: write | ||||||||||||
| pull-requests: write | ||||||||||||
| steps: | ||||||||||||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||||||||
| - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | ||||||||||||
| with: | ||||||||||||
| node-version-file: '.node-version' | ||||||||||||
| cache: 'npm' | ||||||||||||
| - name: Regenerate lock file | ||||||||||||
| run: npm install --package-lock-only --ignore-scripts | ||||||||||||
| - name: Create PR if lock file drifted | ||||||||||||
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step uses the default Pass a PAT or GitHub App token to let the created PR trigger normal CI:
Suggested change
|
||||||||||||
| with: | ||||||||||||
| commit-message: 'chore: sync package-lock.json with package.json' | ||||||||||||
| branch: chore/sync-lockfile | ||||||||||||
| delete-branch: true | ||||||||||||
| title: 'chore: sync package-lock.json with package.json' | ||||||||||||
| body: | | ||||||||||||
| `package-lock.json` has drifted from `package.json`. This PR regenerates the lock file. | ||||||||||||
|
|
||||||||||||
| Generated by the [Sync Lock File](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow. | ||||||||||||
| labels: dependencies | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may wanna borrow what we do in
rocksdb-js: https://github.com/HarperFast/rocksdb-js/blob/main/.github/workflows/formatting.yml#L54-L64