|
| 1 | +name: Update Third-Party Attributions |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 3 * * *" # nightly 03:00 UTC |
| 7 | + pull_request: |
| 8 | + branches: [master] |
| 9 | + paths: |
| 10 | + - .github/workflows/attribution.yml |
| 11 | + - .github/scripts/build-attribution.sh |
| 12 | + - ATTRIBUTIONS.md |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + attribution: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v6 |
| 24 | + |
| 25 | + - name: Fetch dependency inventory |
| 26 | + uses: vespa-engine/gh-actions/mend-inventory@217825ab3497a98c67134a9e8bb30f04329e82fe # v1 |
| 27 | + with: |
| 28 | + mend-project-name: GH_vespa_master |
| 29 | + mend-project-uuid: dbdbea81-7f52-426c-974f-975c2848770d |
| 30 | + mend-user: ${{ vars.MEND_ATTRIBUTION_USER_EMAIL }} |
| 31 | + mend-api-key: ${{ secrets.MEND_ATTRIBUTION_USER_KEY }} |
| 32 | + output-path: build/inventory.json |
| 33 | + |
| 34 | + - name: Build ATTRIBUTIONS.md |
| 35 | + run: | |
| 36 | + ./.github/scripts/build-attribution.sh build/inventory.json > ATTRIBUTIONS.md |
| 37 | + echo "Wrote $(wc -l < ATTRIBUTIONS.md) lines to ATTRIBUTIONS.md" |
| 38 | +
|
| 39 | + # Only uploaded on failure so the raw response is available for debugging |
| 40 | + # without bloating the artifact list on every successful run. |
| 41 | + - name: Upload raw inventory JSON (debug, on failure) |
| 42 | + if: ${{ failure() }} |
| 43 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 |
| 44 | + with: |
| 45 | + name: inventory-debug |
| 46 | + path: build/inventory.json |
| 47 | + retention-days: 7 |
| 48 | + if-no-files-found: warn |
| 49 | + |
| 50 | + - name: Upload ATTRIBUTIONS.md |
| 51 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 |
| 52 | + with: |
| 53 | + name: attributions |
| 54 | + path: ATTRIBUTIONS.md |
| 55 | + retention-days: 14 |
| 56 | + |
| 57 | + - name: Open PR if changed |
| 58 | + if: ${{ github.event_name != 'pull_request' }} |
| 59 | + env: |
| 60 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 64 | + git config user.name "github-actions[bot]" |
| 65 | +
|
| 66 | + git add ATTRIBUTIONS.md |
| 67 | + if git diff --cached --quiet; then |
| 68 | + echo "ATTRIBUTIONS.md is up to date — nothing to do." |
| 69 | + exit 0 |
| 70 | + fi |
| 71 | +
|
| 72 | + BRANCH="chore/update-attributions" |
| 73 | + git checkout -B "$BRANCH" |
| 74 | + git commit -m "chore: update third-party attributions" |
| 75 | + git push --force --set-upstream origin "$BRANCH" |
| 76 | +
|
| 77 | + if gh pr view "$BRANCH" --json state --jq .state 2>/dev/null | grep -q OPEN; then |
| 78 | + echo "PR for $BRANCH already open — pushed update to existing PR." |
| 79 | + else |
| 80 | + gh pr create \ |
| 81 | + --base master \ |
| 82 | + --head "$BRANCH" \ |
| 83 | + --title "chore: update third-party attributions" \ |
| 84 | + --body "Auto-generated update of ATTRIBUTIONS.md." |
| 85 | + fi |
0 commit comments