Skip to content

Commit e48960e

Browse files
Generate license.json via GitHub Actions after deps updates (#38)
1 parent 259e4be commit e48960e

File tree

3 files changed

+102
-40
lines changed

3 files changed

+102
-40
lines changed

.github/workflows/update-licenses.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Update Licenses on Dependency Changes
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- "package.json"
9+
- "pnpm-lock.yaml"
10+
types:
11+
- opened
12+
- synchronize
13+
- reopened
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
jobs:
20+
update-licenses:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.pull_request.head.ref || 'master' }}
28+
29+
- name: Set up pnpm
30+
uses: pnpm/action-setup@v4
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: "lts/*"
36+
cache: pnpm
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Generate licenses.json
42+
run: |
43+
pnpm add -g license-checker
44+
license-checker --json > licenses.json
45+
46+
- name: Display licenses.json content
47+
run: cat licenses.json
48+
49+
- name: Commit and push updated licenses
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
git config --global user.name "github-actions[bot]"
54+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
55+
git add licenses.json
56+
if ! git diff --cached --quiet; then
57+
git commit -m "chore: Update licenses.json"
58+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
59+
git push origin HEAD:${{ github.event.pull_request.head.ref || 'master' }}
60+
else
61+
echo "No changes to commit."
62+
fi

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@swc/core": "^1.10.12",
2424
"@swc/helpers": "^0.5.15",
2525
"@types/jest": "^29.5.14",
26-
"@types/node": "^22.12.0",
26+
"@types/node": "^22.13.0",
2727
"jest": "^29.7.0",
2828
"nodemon": "^3.1.9",
2929
"rimraf": "^6.0.1",

pnpm-lock.yaml

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)