Skip to content

Commit cbb2e0c

Browse files
committed
update PR review workflow with fork-supporting trigger
Signed-off-by: Derek Misler <derek.misler@docker.com>
1 parent d9c5b53 commit cbb2e0c

2 files changed

Lines changed: 48 additions & 14 deletions

File tree

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]
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: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
name: PR Review
22
on:
3-
issue_comment: # Enables /review command in PR comments
3+
issue_comment:
44
types: [created]
5-
pull_request_review_comment: # Captures feedback on review comments for learning
6-
types: [created]
7-
pull_request: # Triggers auto-review on PR open (same-repo branches only; fork PRs use /review)
8-
types: [ready_for_review, opened]
5+
workflow_run:
6+
workflows: ["PR Review - Trigger"]
7+
types: [completed]
98

109
permissions:
1110
contents: read # Required at top-level to give `issue_comment` events access to the secrets below.
1211

1312
jobs:
1413
review:
15-
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@ec4865576952df6285652f2cf8ffb4ad45ff5f80 # v1.4.3
1618
# Scoped to the job so other jobs in this workflow aren't over-permissioned
1719
permissions:
1820
contents: read # Read repository files and PR diffs
19-
pull-requests: write # Post review comments and approve/request changes
20-
issues: write # Create security incident issues if secrets are detected in output
21-
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
2224
id-token: write # Required for OIDC authentication to AWS Secrets Manager
23-
secrets:
24-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
25-
CAGENT_ORG_MEMBERSHIP_TOKEN: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN }} # PAT with read:org scope; gates auto-reviews to org members only
26-
CAGENT_REVIEWER_APP_ID: ${{ secrets.CAGENT_REVIEWER_APP_ID }} # GitHub App ID; reviews appear as your app instead of github-actions[bot]
27-
CAGENT_REVIEWER_APP_PRIVATE_KEY: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} # GitHub App private key; paired with App ID above
25+
actions: read # Download artifacts from trigger workflow
26+
with:
27+
trigger-run-id: ${{ github.event_name == 'workflow_run' && format('{0}', github.event.workflow_run.id) || '' }}
28+

0 commit comments

Comments
 (0)