|
| 1 | +# ============================================================================= |
| 2 | +# SDK Review Relay |
| 3 | +# |
| 4 | +# Minimal relay that forwards pull_request_review events to gdc-nas, |
| 5 | +# where the actual review-fix logic runs. Only fires for [AUTO] PRs |
| 6 | +# created by the SDK sync pipeline. |
| 7 | +# |
| 8 | +# SECRETS |
| 9 | +# ------- |
| 10 | +# TOKEN_GITHUB_YENKINS_ADMIN — PAT with repo scope on gdc-nas |
| 11 | +# (needed for repository_dispatch) |
| 12 | +# ============================================================================= |
| 13 | +name: SDK Review Relay |
| 14 | + |
| 15 | +on: |
| 16 | + pull_request_review: |
| 17 | + types: [submitted] |
| 18 | + |
| 19 | +jobs: |
| 20 | + relay: |
| 21 | + name: "Forward review to gdc-nas" |
| 22 | + if: >- |
| 23 | + (github.event.review.state == 'changes_requested' |
| 24 | + || (github.event.review.state == 'commented' && github.event.review.body)) |
| 25 | + && github.event.pull_request.user.login == 'yenkins-admin' |
| 26 | + && startsWith(github.event.pull_request.head.ref, 'feature/auto-P') |
| 27 | + && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name |
| 28 | + runs-on: ubuntu-latest |
| 29 | + timeout-minutes: 2 |
| 30 | + steps: |
| 31 | + - name: Dispatch to gdc-nas |
| 32 | + env: |
| 33 | + GH_TOKEN: ${{ secrets.TOKEN_GITHUB_YENKINS_ADMIN }} |
| 34 | + REVIEW_BODY: ${{ github.event.review.body }} |
| 35 | + run: | |
| 36 | + # Build JSON payload safely (review_body may contain quotes/newlines) |
| 37 | + jq -nc \ |
| 38 | + --arg pr_number "${{ github.event.pull_request.number }}" \ |
| 39 | + --arg pr_branch "${{ github.event.pull_request.head.ref }}" \ |
| 40 | + --arg pr_author "${{ github.event.pull_request.user.login }}" \ |
| 41 | + --arg reviewer "${{ github.event.review.user.login }}" \ |
| 42 | + --arg review_id "${{ github.event.review.id }}" \ |
| 43 | + --arg review_state "${{ github.event.review.state }}" \ |
| 44 | + --arg review_body "$REVIEW_BODY" \ |
| 45 | + '{ |
| 46 | + event_type: "sdk-review-submitted", |
| 47 | + client_payload: { |
| 48 | + pr_number: $pr_number, |
| 49 | + pr_branch: $pr_branch, |
| 50 | + pr_author: $pr_author, |
| 51 | + reviewer: $reviewer, |
| 52 | + review_id: $review_id, |
| 53 | + review_state: $review_state, |
| 54 | + review_body: $review_body |
| 55 | + } |
| 56 | + }' | gh api "repos/gooddata/gdc-nas/dispatches" \ |
| 57 | + --method POST \ |
| 58 | + --input - |
| 59 | +
|
| 60 | + echo "## Dispatched to gdc-nas" >> "$GITHUB_STEP_SUMMARY" |
| 61 | + echo "- PR: #${{ github.event.pull_request.number }}" >> "$GITHUB_STEP_SUMMARY" |
| 62 | + echo "- Reviewer: ${{ github.event.review.user.login }}" >> "$GITHUB_STEP_SUMMARY" |
| 63 | + echo "- State: ${{ github.event.review.state }}" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments