|
5 | 5 | types: [opened, synchronize, reopened] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - check-permissions: |
9 | | - runs-on: ubuntu-latest |
10 | | - outputs: |
11 | | - HAS_SECRETS: ${{ steps.check.outputs.HAS_SECRETS }} |
12 | | - steps: |
13 | | - - run: echo "HAS_SECRETS=${{ secrets.WARDEN_PRIVATE_KEY != '' }}" >> "$GITHUB_OUTPUT" |
14 | | - id: check |
15 | | - |
16 | 8 | warden: |
17 | 9 | runs-on: ubuntu-latest |
18 | | - needs: check-permissions |
19 | | - if: ${{ needs.check-permissions.outputs.HAS_SECRETS == 'true' }} |
20 | 10 | permissions: |
21 | 11 | contents: read |
22 | 12 | pull-requests: read |
|
26 | 16 | WARDEN_MODEL: ${{ secrets.WARDEN_MODEL }} |
27 | 17 | WARDEN_SENTRY_DSN: ${{ secrets.WARDEN_SENTRY_DSN }} |
28 | 18 | steps: |
| 19 | + - name: Check Warden credentials |
| 20 | + env: |
| 21 | + HAS_OPENROUTER_API_KEY: ${{ secrets.WARDEN_OPENROUTER_API_KEY != '' }} |
| 22 | + IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }} |
| 23 | + IS_DEPENDABOT: ${{ github.actor == 'dependabot[bot]' }} |
| 24 | + run: | |
| 25 | + if [[ "$HAS_OPENROUTER_API_KEY" == "true" ]]; then |
| 26 | + exit 0 |
| 27 | + fi |
| 28 | +
|
| 29 | + if [[ "$IS_FORK" == "true" ]]; then |
| 30 | + MESSAGE="Warden cannot review this fork pull request because GitHub withholds repository secrets from fork workflows." |
| 31 | + elif [[ "$IS_DEPENDABOT" == "true" ]]; then |
| 32 | + MESSAGE="Warden cannot review this Dependabot pull request because WARDEN_OPENROUTER_API_KEY is unavailable. Add it to the organization Dependabot secrets." |
| 33 | + else |
| 34 | + MESSAGE="Warden cannot review this pull request because WARDEN_OPENROUTER_API_KEY is unavailable. Add it to the organization Actions secrets." |
| 35 | + fi |
| 36 | +
|
| 37 | + echo "::error::$MESSAGE" |
| 38 | + printf '## Warden unavailable\n\n%s\n' "$MESSAGE" >> "$GITHUB_STEP_SUMMARY" |
| 39 | + exit 1 |
| 40 | +
|
29 | 41 | - name: Checkout Code |
30 | 42 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
31 | 43 |
|
|
38 | 50 | - name: Analyze |
39 | 51 | id: warden-analyze |
40 | 52 | uses: getsentry/warden@v0 |
41 | | - continue-on-error: true |
42 | 53 | with: |
43 | 54 | mode: analyze |
44 | 55 | base-config-path: .warden-org/warden.toml |
|
54 | 65 | - name: Report |
55 | 66 | if: ${{ always() && steps.warden-analyze.outputs.findings-file != '' && steps.app-token.outcome == 'success' }} |
56 | 67 | uses: getsentry/warden@v0 |
57 | | - continue-on-error: true |
58 | 68 | with: |
59 | 69 | mode: report |
60 | 70 | findings-file: ${{ steps.warden-analyze.outputs.findings-file }} |
|
0 commit comments