Skip to content

Commit 2eb69c1

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

File tree

4 files changed

+114
-41
lines changed

4 files changed

+114
-41
lines changed

.github/workflows/general-ci.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: General CI Workflow
22

33
on:
4+
push:
5+
branches:
6+
- "**"
7+
48
pull_request:
59
branches:
6-
- master
10+
- "**"
711

812
jobs:
913
test-and-build:

.github/workflows/update-licenses.yml

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

package.json

+1-1
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

+39-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)