Skip to content

Commit f1e2678

Browse files
committed
package lock regen gh action
1 parent f7b247b commit f1e2678

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Regenerate Lockfile
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to update'
8+
required: false
9+
default: 'main'
10+
11+
jobs:
12+
regenerate:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
ref: ${{ github.event.inputs.branch }}
23+
fetch-depth: 0
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
30+
- name: Remove existing lockfile
31+
run: rm -rf node_modules package-lock.json
32+
33+
- name: Generate Linux-friendly lockfile
34+
run: npm install --ignore-scripts
35+
36+
- name: Configure Git author
37+
run: |
38+
git config --local user.email "action@github.com"
39+
git config --local user.name "GitHub Action"
40+
41+
- name: Commit lockfile
42+
id: commit
43+
run: |
44+
if git diff --quiet -- package-lock.json; then
45+
echo "changed=false" >> "$GITHUB_OUTPUT"
46+
echo "No changes detected"
47+
else
48+
git add package-lock.json
49+
git commit -m "chore: regenerate package-lock on Linux"
50+
echo "changed=true" >> "$GITHUB_OUTPUT"
51+
fi
52+
53+
- name: Push changes
54+
if: steps.commit.outputs.changed == 'true'
55+
env:
56+
BRANCH: ${{ github.event.inputs.branch }}
57+
run: git push origin HEAD:${BRANCH}

0 commit comments

Comments
 (0)