diff --git a/.github/workflows/pr-review-trigger.yml b/.github/workflows/pr-review-trigger.yml new file mode 100644 index 000000000..1ecc03b09 --- /dev/null +++ b/.github/workflows/pr-review-trigger.yml @@ -0,0 +1,42 @@ +name: PR Review - Trigger +on: + pull_request: + types: [ready_for_review, opened, review_requested] + pull_request_review_comment: + types: [created] + +permissions: {} + +# Deduplicate simultaneous pull_request events for the same fork PR. +# When reviewers are requested at the same time, GitHub fires multiple +# review_requested events. Without this group each event triggers a +# separate review via workflow_run, producing duplicate reviews. +concurrency: + group: pr-review-trigger-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + save-context: + if: github.event.pull_request.head.repo.fork + runs-on: ubuntu-latest + steps: + - name: Save event context + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + COMMENT_JSON: ${{ toJSON(github.event.comment) }} + run: | + mkdir -p context + printf '%s' "${{ github.event_name }}" > context/event_name.txt + printf '%s' "$PR_NUMBER" > context/pr_number.txt + printf '%s' "$PR_HEAD_SHA" > context/pr_head_sha.txt + if [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then + printf '%s' "$COMMENT_JSON" > context/comment.json + fi + + - name: Upload context + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pr-review-context + path: context/ + retention-days: 1 diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml new file mode 100644 index 000000000..1f459fc27 --- /dev/null +++ b/.github/workflows/pr-review.yml @@ -0,0 +1,23 @@ +name: PR Review +on: + issue_comment: + types: [created] + workflow_run: + workflows: ["PR Review - Trigger"] + types: [completed] + +permissions: + contents: read + +jobs: + review: + uses: docker/docker-agent-action/.github/workflows/review-pr.yml@774b6e0e60d6c648b0f2dc43bd5221377a0a7420 # v2.0.2 + permissions: + contents: read # Read repository files and PR diffs + pull-requests: write # Post review comments + issues: write # Create security incident issues if secrets detected + checks: write # (Optional) Show review progress as a check run + id-token: write # Required for OIDC authentication to AWS Secrets Manager + actions: read # Download artifacts from trigger workflow + with: + trigger-run-id: ${{ github.event_name == 'workflow_run' && format('{0}', github.event.workflow_run.id) || '' }}