|
| 1 | +# Dependency Review Action |
| 2 | +# |
| 3 | +# This Action will scan dependency manifest files that change as part of a Pull Request, |
| 4 | +# surfacing known-vulnerable versions of the packages declared or updated in the PR. |
| 5 | +# Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable |
| 6 | +# packages will be blocked from merging. |
| 7 | +# |
| 8 | +# Source repository: https://github.com/actions/dependency-review-action |
| 9 | +# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement |
| 10 | +name: 'Dependency review' |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + branches: [ "master"] |
| 14 | + merge_group: |
| 15 | + branches: [ "master"] |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +# If using a dependency submission action in this workflow this permission will need to be set to: |
| 22 | +# |
| 23 | +# permissions: |
| 24 | +# contents: write |
| 25 | +# |
| 26 | +# https://docs.github.com/en/enterprise-cloud@latest/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api |
| 27 | + |
| 28 | +jobs: |
| 29 | + dependency-review: |
| 30 | + if: github.event_name == 'pull_request' |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + pull-requests: write # Only needed for comment-summary-in-pr |
| 34 | + runs-on: ${{ vars.ACTIVE_RUNNER_LABEL }} |
| 35 | + steps: |
| 36 | + - name: 'Check if dependency files changed' |
| 37 | + id: should_run |
| 38 | + env: |
| 39 | + GH_TOKEN: ${{ github.token }} |
| 40 | + run: | |
| 41 | + # Check if dependency files changed using GitHub API |
| 42 | + CHANGED_FILES=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --jq '.[].filename') |
| 43 | + if echo "$CHANGED_FILES" | grep -qE '^(package\.json|yarn\.lock)$'; then |
| 44 | + echo "Dependency files changed - will run review" |
| 45 | + echo "run=true" >> $GITHUB_OUTPUT |
| 46 | + else |
| 47 | + echo "No dependency changes - skipping review" |
| 48 | + echo "run=false" >> $GITHUB_OUTPUT |
| 49 | + fi |
| 50 | + - name: 'Checkout repository' |
| 51 | + if: steps.should_run.outputs.run == 'true' |
| 52 | + uses: swan-bitcoin/actions/actions/checkout@master |
| 53 | + with: |
| 54 | + fetch-depth: 1 |
| 55 | + fetch-tags: false |
| 56 | + - name: 'Dependency Review' |
| 57 | + if: steps.should_run.outputs.run == 'true' |
| 58 | + uses: swan-bitcoin/actions/actions/dependency-review-action@master |
| 59 | + # Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options. |
| 60 | + with: |
| 61 | + comment-summary-in-pr: on-failure |
| 62 | + license-check: false |
| 63 | + fail-on-severity: high |
| 64 | + # deny-licenses: GPL-1.0-or-later, LGPL-2.0-or-later |
| 65 | + # retry-on-snapshot-warnings: true |
| 66 | + |
| 67 | + analyze-dependency-changes: |
| 68 | + if: github.event_name == 'pull_request' |
| 69 | + permissions: |
| 70 | + contents: read |
| 71 | + pull-requests: read |
| 72 | + runs-on: ${{ vars.ACTIVE_RUNNER_LABEL }} |
| 73 | + steps: |
| 74 | + - name: 'Check if dependency files changed' |
| 75 | + id: should_run |
| 76 | + env: |
| 77 | + GH_TOKEN: ${{ github.token }} |
| 78 | + run: | |
| 79 | + # Check if dependency files changed using GitHub API |
| 80 | + CHANGED_FILES=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --jq '.[].filename') |
| 81 | + if echo "$CHANGED_FILES" | grep -qE '^(package\.json|yarn\.lock)$'; then |
| 82 | + echo "Dependency files changed - will run analysis" |
| 83 | + echo "run=true" >> $GITHUB_OUTPUT |
| 84 | + else |
| 85 | + echo "No dependency changes - skipping analysis" |
| 86 | + echo "run=false" >> $GITHUB_OUTPUT |
| 87 | + fi |
| 88 | + - name: 'Checkout repository' |
| 89 | + if: steps.should_run.outputs.run == 'true' |
| 90 | + uses: swan-bitcoin/actions/actions/checkout@master |
| 91 | + with: |
| 92 | + fetch-depth: 1 |
| 93 | + fetch-tags: false |
| 94 | + - name: 'Analyze Dependency Changes' |
| 95 | + if: steps.should_run.outputs.run == 'true' |
| 96 | + uses: swan-bitcoin/actions/swan/analyze-dependencies@master |
| 97 | + with: |
| 98 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
0 commit comments