Skip to content

Commit aa6f651

Browse files
authored
Merge pull request #24983 from derekmisler/remove-usage-of-cagent-org-secrets-in-docs-repo
remove usage of CAGENT_* org secrets in docs repo
2 parents 5fb0fb2 + fec0423 commit aa6f651

3 files changed

Lines changed: 69 additions & 29 deletions

File tree

.github/workflows/nightly-docs-scan.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ jobs:
2323
scan:
2424
runs-on: ubuntu-latest
2525
timeout-minutes: 20
26-
env:
27-
HAS_APP_SECRETS: ${{ secrets.CAGENT_REVIEWER_APP_ID != '' }}
26+
permissions:
27+
id-token: write
28+
contents: read
29+
issues: write
2830

2931
steps:
3032
- name: Checkout repository
@@ -45,24 +47,33 @@ jobs:
4547
restore-keys: |
4648
docs-scanner-state-${{ github.repository }}-
4749
48-
- name: Generate GitHub App token
49-
if: env.HAS_APP_SECRETS == 'true'
50-
id: app-token
50+
- name: Configure AWS credentials
51+
id: aws-credentials
5152
continue-on-error: true
52-
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
53+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4
5354
with:
54-
app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }}
55-
private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }}
55+
role-to-assume: arn:aws:iam::710015040892:role/docker-agent-action-20260409141318957000000001
56+
aws-region: us-east-1
57+
58+
- name: Fetch bot PAT
59+
if: steps.aws-credentials.outcome == 'success'
60+
run: |
61+
PAT=$(aws secretsmanager get-secret-value \
62+
--secret-id docker-agent-action/github-app \
63+
--query SecretString \
64+
--output text | jq -r '.pat')
65+
echo "::add-mask::$PAT"
66+
echo "GITHUB_APP_TOKEN=$PAT" >> "$GITHUB_ENV"
5667
5768
- name: Run documentation scan
5869
uses: docker/cagent-action@3a12dbd0c6cd7dda3d4e05f24f0143c9701456de # latest
5970
env:
60-
GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
71+
GH_TOKEN: ${{ env.GITHUB_APP_TOKEN || github.token }}
6172
with:
6273
agent: ${{ github.workspace }}/.github/agents/docs-scanner.yaml
63-
prompt: "${{ inputs['dry-run'] && 'DRY RUN MODE: Do not create any GitHub issues. Report what you would create but skip the gh issue create commands.' || 'Run the nightly documentation scan as described in your instructions.' }}"
74+
prompt: "${{ inputs.dry-run == true && 'DRY RUN MODE: Do not create any GitHub issues. Report what you would create but skip the gh issue create commands.' || 'Run the nightly documentation scan as described in your instructions.' }}"
6475
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
65-
github-token: ${{ steps.app-token.outputs.token || github.token }}
76+
github-token: ${{ env.GITHUB_APP_TOKEN || github.token }}
6677
timeout: 1200
6778

6879
- name: Save scanner state
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PR Review - Trigger
2+
on:
3+
pull_request:
4+
types: [ready_for_review, opened, review_requested]
5+
pull_request_review_comment:
6+
types: [created]
7+
8+
permissions: {}
9+
10+
jobs:
11+
save-context:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Save event context
15+
env:
16+
PR_NUMBER: ${{ github.event.pull_request.number }}
17+
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
18+
COMMENT_JSON: ${{ toJSON(github.event.comment) }}
19+
run: |
20+
mkdir -p context
21+
printf '%s' "${{ github.event_name }}" > context/event_name.txt
22+
printf '%s' "$PR_NUMBER" > context/pr_number.txt
23+
printf '%s' "$PR_HEAD_SHA" > context/pr_head_sha.txt
24+
if [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
25+
printf '%s' "$COMMENT_JSON" > context/comment.json
26+
fi
27+
28+
- name: Upload context
29+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
30+
with:
31+
name: pr-review-context
32+
path: context/
33+
retention-days: 1

.github/workflows/pr-review.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
# Thin wrapper around docker/cagent-action's reusable review workflow.
2-
# Fork detection, org-membership gating, and review posting are all handled
3-
# by the reusable workflow, so no additional guards are needed here.
4-
#
5-
# Triggers:
6-
# issue_comment — `/review` slash command (works for fork contributors).
7-
# pull_request_review_comment — captures feedback for agent learning.
81
name: PR Review
9-
102
on:
113
issue_comment:
124
types: [created]
13-
pull_request_review_comment:
14-
types: [created]
15-
pull_request:
16-
types: [ready_for_review, opened]
5+
workflow_run:
6+
workflows: ["PR Review - Trigger"]
7+
types: [completed]
178

189
permissions:
19-
contents: read
10+
contents: read # Required at top-level to give `issue_comment` events access to the secrets below.
2011

2112
jobs:
2213
review:
23-
uses: docker/cagent-action/.github/workflows/review-pr.yml@d98096f432f2aea5091c811852c4da804e60623a # v1.4.1
14+
if: |
15+
github.event_name == 'issue_comment' ||
16+
github.event.workflow_run.conclusion == 'success'
17+
uses: docker/cagent-action/.github/workflows/review-pr.yml@c22076b8856ee12d9b4c4685bb49cf26eb974079 # v1.5.0
2418
# Scoped to the job so other jobs in this workflow aren't over-permissioned
2519
permissions:
2620
contents: read # Read repository files and PR diffs
27-
pull-requests: write # Post review comments and approve/request changes
28-
issues: write # Create security incident issues if secrets are detected in output
29-
checks: write # (Optional) Show review progress as a check run on the PR
21+
pull-requests: write # Post review comments
22+
issues: write # Create security incident issues if secrets detected
23+
checks: write # (Optional) Show review progress as a check run
3024
id-token: write # Required for OIDC authentication to AWS Secrets Manager
25+
actions: read # Download artifacts from trigger workflow
3126
with:
27+
trigger-run-id: ${{ github.event_name == 'workflow_run' && format('{0}', github.event.workflow_run.id) || '' }}
3228
add-prompt-files: STYLE.md,COMPONENTS.md
3329
additional-prompt: |
3430
## Documentation Review Focus
@@ -85,4 +81,4 @@ jobs:
8581
- **medium**: Could confuse users or violates style guide (AI-isms, scope inflation, unclear instructions, markdown formatting)
8682
- **low**: Minor suggestions (rarely report)
8783
88-
Most issues should be MEDIUM. HIGH is for critical problems only.
84+
Most issues should be MEDIUM. HIGH is for critical problems only.

0 commit comments

Comments
 (0)