-
Notifications
You must be signed in to change notification settings - Fork 5
ci: add workflow to auto-regenerate licenses for Dependabot PRs #387
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
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,93 @@ | ||||||||||||||||||
| # | ||||||||||||||||||
| # Copyright (c) 2022-2026 | ||||||||||||||||||
| # This program and the accompanying materials are made | ||||||||||||||||||
| # available under the terms of the Eclipse Public License 2.0 | ||||||||||||||||||
| # which is available at https://www.eclipse.org/legal/epl-2.0/ | ||||||||||||||||||
| # | ||||||||||||||||||
| # SPDX-License-Identifier: EPL-2.0 | ||||||||||||||||||
| # | ||||||||||||||||||
|
|
||||||||||||||||||
| name: Dependabot License Update | ||||||||||||||||||
|
|
||||||||||||||||||
| on: | ||||||||||||||||||
| pull_request: | ||||||||||||||||||
| types: [opened, synchronize] | ||||||||||||||||||
| branches: | ||||||||||||||||||
| - main | ||||||||||||||||||
|
|
||||||||||||||||||
| permissions: | ||||||||||||||||||
| contents: write | ||||||||||||||||||
|
|
||||||||||||||||||
| jobs: | ||||||||||||||||||
| update-licenses: | ||||||||||||||||||
| runs-on: ubuntu-22.04 | ||||||||||||||||||
| if: github.event.pull_request.user.login == 'dependabot[bot]' | ||||||||||||||||||
| steps: | ||||||||||||||||||
| - name: Checkout | ||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||
| with: | ||||||||||||||||||
| ref: ${{ github.head_ref }} | ||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Use Node 24 | ||||||||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||||||||
| with: | ||||||||||||||||||
| node-version: 24 | ||||||||||||||||||
|
Comment on lines
+32
to
+35
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. Security: Pin action to commit SHA. The action reference should be pinned to a specific commit SHA hash to prevent supply chain attacks. 🔒 Recommended fix - name: Use Node 24
- uses: actions/setup-node@v4
+ uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 24Note: The commit SHA corresponds to actions/setup-node@v4.1.0. Verify the latest secure version before applying. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.25.2)[error] 33-33: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||
| run: yarn install | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Regenerate licenses | ||||||||||||||||||
| run: | | ||||||||||||||||||
| MAX_ATTEMPTS=3 | ||||||||||||||||||
| for attempt in $(seq 1 $MAX_ATTEMPTS); do | ||||||||||||||||||
| echo "=== Attempt $attempt of $MAX_ATTEMPTS ===" | ||||||||||||||||||
|
|
||||||||||||||||||
| if yarn license:generate; then | ||||||||||||||||||
| echo "License generation succeeded." | ||||||||||||||||||
| break | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if [ ! -f .deps/problems.md ]; then | ||||||||||||||||||
| echo "::error::License generation failed but no problems.md found." | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| SECTION="" | ||||||||||||||||||
| while IFS= read -r line; do | ||||||||||||||||||
| if echo "$line" | grep -q "## UNRESOLVED Production dependencies"; then | ||||||||||||||||||
| SECTION="prod" | ||||||||||||||||||
| elif echo "$line" | grep -q "## UNRESOLVED Development dependencies"; then | ||||||||||||||||||
| SECTION="dev" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| PKG=$(echo "$line" | grep -oP '`\K[^`]+' || true) | ||||||||||||||||||
| if [ -z "$PKG" ] || [ -z "$SECTION" ]; then | ||||||||||||||||||
| continue | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| EXCLUDED_FILE=".deps/EXCLUDED/${SECTION}.md" | ||||||||||||||||||
| if grep -qF "\`${PKG}\`" "$EXCLUDED_FILE" 2>/dev/null; then | ||||||||||||||||||
| echo "Already excluded: $PKG" | ||||||||||||||||||
| continue | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "| \`${PKG}\` | transitive dependency |" >> "$EXCLUDED_FILE" | ||||||||||||||||||
| echo "Added $PKG to $EXCLUDED_FILE" | ||||||||||||||||||
| done < .deps/problems.md | ||||||||||||||||||
|
|
||||||||||||||||||
| if [ "$attempt" -eq "$MAX_ATTEMPTS" ]; then | ||||||||||||||||||
| echo "::error::Failed to resolve all dependencies after $MAX_ATTEMPTS attempts." | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
| done | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Commit and push changes | ||||||||||||||||||
| run: | | ||||||||||||||||||
| git diff --quiet .deps/ && exit 0 | ||||||||||||||||||
|
|
||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||
| git add .deps/ | ||||||||||||||||||
| git commit -s -m "chore(deps): regenerate license dependencies" | ||||||||||||||||||
| git push | ||||||||||||||||||
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.
Security: Prevent credential persistence and pin action version.
Two security concerns:
persist-credentials: falseallows the GitHub token to persist in the local git config, potentially leaking through artifacts or logs.🔒 Recommended security hardening
Note: The commit SHA corresponds to actions/checkout@v4.2.2. Verify the latest secure version before applying.
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.25.2)
[warning] 26-30: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[error] 27-27: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for AI Agents