Skip to content

Commit 56010fb

Browse files
sentry-junior[bot]juniordcramer
authored
fix(warden): Fail clearly when credentials are unavailable (#202)
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: junior <noreply@getsentry.com> Co-authored-by: David Cramer <david@sentry.io>
1 parent ce74f49 commit 56010fb

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

.github/workflows/warden.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@ on:
55
types: [opened, synchronize, reopened]
66

77
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-
168
warden:
179
runs-on: ubuntu-latest
18-
needs: check-permissions
19-
if: ${{ needs.check-permissions.outputs.HAS_SECRETS == 'true' }}
2010
permissions:
2111
contents: read
2212
pull-requests: read
@@ -26,6 +16,28 @@ jobs:
2616
WARDEN_MODEL: ${{ secrets.WARDEN_MODEL }}
2717
WARDEN_SENTRY_DSN: ${{ secrets.WARDEN_SENTRY_DSN }}
2818
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+
2941
- name: Checkout Code
3042
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3143

@@ -38,7 +50,6 @@ jobs:
3850
- name: Analyze
3951
id: warden-analyze
4052
uses: getsentry/warden@v0
41-
continue-on-error: true
4253
with:
4354
mode: analyze
4455
base-config-path: .warden-org/warden.toml
@@ -54,7 +65,6 @@ jobs:
5465
- name: Report
5566
if: ${{ always() && steps.warden-analyze.outputs.findings-file != '' && steps.app-token.outcome == 'success' }}
5667
uses: getsentry/warden@v0
57-
continue-on-error: true
5868
with:
5969
mode: report
6070
findings-file: ${{ steps.warden-analyze.outputs.findings-file }}

0 commit comments

Comments
 (0)