Skip to content

Commit f23f918

Browse files
typotterclaude
andcommitted
feat: add auto-update licenses workflow for PRs
Create a new GitHub Action workflow that automatically updates the LICENSE-3rdparty.csv file on pull requests when dependencies change. The workflow: - Triggers on changes to yarn.lock, package.json files, or .ddla-overrides - Only runs on PRs from the same repository (not forks) - Generates the license file using dd-license-attribution - Commits and pushes changes back to the PR branch if needed - Uses github-actions bot for commits This ensures license files stay in sync with dependencies automatically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
1 parent 1bb69c5 commit f23f918

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Auto-update Licenses
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- 'yarn.lock'
8+
- 'package.json'
9+
- '**/package.json'
10+
- '.ddla-overrides'
11+
12+
permissions:
13+
contents: write
14+
packages: read
15+
16+
jobs:
17+
update-licenses:
18+
# Only run on PRs from the same repository (not forks)
19+
if: github.event.pull_request.head.repo.full_name == github.repository
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out the repository
23+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
with:
25+
ref: ${{ github.event.pull_request.head.ref }}
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
30+
with:
31+
python-version: '3.11.12'
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v5.0.0
35+
with:
36+
node-version: '18'
37+
cache: 'yarn'
38+
39+
- name: Set up Golang
40+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # 6.0.0
41+
with:
42+
go-version: '1.23'
43+
44+
- name: Clone dd-license-attribution
45+
run: |
46+
git clone https://github.com/DataDog/dd-license-attribution.git /tmp/dd-license-attribution
47+
48+
- name: Install dd-license-attribution
49+
run: |
50+
python -m pip install --upgrade pip
51+
python -m pip install /tmp/dd-license-attribution
52+
53+
- name: Install project dependencies
54+
run: yarn install --frozen-lockfile
55+
56+
- name: Generate licenses
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: yarn licenses:generate
60+
61+
- name: Check for changes
62+
id: check_changes
63+
run: |
64+
if git diff --quiet LICENSE-3rdparty.csv; then
65+
echo "has_changes=false" >> $GITHUB_OUTPUT
66+
else
67+
echo "has_changes=true" >> $GITHUB_OUTPUT
68+
fi
69+
70+
- name: Commit and push changes
71+
if: steps.check_changes.outputs.has_changes == 'true'
72+
run: |
73+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
74+
git config --local user.name "github-actions[bot]"
75+
git add LICENSE-3rdparty.csv
76+
git commit -m "chore: auto-update LICENSE-3rdparty.csv
77+
78+
Updated license file to reflect current dependencies.
79+
80+
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
81+
git push

0 commit comments

Comments
 (0)