feat: add auto-update licenses workflow for PRs #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-update Licenses | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| paths: | ||
| - 'yarn.lock' | ||
| - 'package.json' | ||
| - '**/package.json' | ||
| - '.ddla-overrides' | ||
| permissions: | ||
| contents: write | ||
| packages: read | ||
| jobs: | ||
| update-licenses: | ||
| # Only run on PRs from the same repository (not forks) | ||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out the repository | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Set up Python | ||
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | ||
| with: | ||
| python-version: '3.11.12' | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v5.0.0 | ||
| with: | ||
| node-version: '18' | ||
| cache: 'yarn' | ||
| - name: Set up Golang | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # 6.0.0 | ||
| with: | ||
| go-version: '1.23' | ||
| - name: Clone dd-license-attribution | ||
| run: | | ||
| git clone https://github.com/DataDog/dd-license-attribution.git /tmp/dd-license-attribution | ||
| - name: Install dd-license-attribution | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install /tmp/dd-license-attribution | ||
| - name: Install project dependencies | ||
| run: yarn install --frozen-lockfile | ||
| - name: Generate licenses | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: yarn licenses:generate | ||
| - name: Check for changes | ||
| id: check_changes | ||
| run: | | ||
| if git diff --quiet LICENSE-3rdparty.csv; then | ||
| echo "has_changes=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "has_changes=true" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Commit and push changes | ||
| if: steps.check_changes.outputs.has_changes == 'true' | ||
| run: | | ||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --local user.name "github-actions[bot]" | ||
| git add LICENSE-3rdparty.csv | ||
| git commit -m "chore: auto-update LICENSE-3rdparty.csv | ||
| Updated license file to reflect current dependencies. | ||
| Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | ||
| git push | ||