|
| 1 | +name: SDK Sentinel PR responder relay |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: {} |
| 8 | + |
| 9 | +jobs: |
| 10 | + relay: |
| 11 | + if: >- |
| 12 | + github.event.issue.pull_request && |
| 13 | + github.event.comment.user.login != 'sdk-sentinel-bot' && |
| 14 | + contains(github.event.comment.body, '@sdk-sentinel-bot') && |
| 15 | + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 5 |
| 18 | + steps: |
| 19 | + - name: Mint a Sentinel-only dispatch token from the Relay App |
| 20 | + id: dispatch-token |
| 21 | + uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2 |
| 22 | + with: |
| 23 | + app-id: ${{ vars.SDK_SENTINEL_RELAY_APP_ID }} |
| 24 | + private-key: ${{ secrets.SDK_SENTINEL_RELAY_PRIVATE_KEY }} |
| 25 | + owner: temporalio |
| 26 | + repositories: sdk-sentinel |
| 27 | + permission-actions: write |
| 28 | + permission-metadata: read |
| 29 | + - name: Verify the Sentinel Relay installation |
| 30 | + env: |
| 31 | + ACTUAL_APP_SLUG: ${{ steps.dispatch-token.outputs.app-slug }} |
| 32 | + ACTUAL_INSTALLATION_ID: ${{ steps.dispatch-token.outputs.installation-id }} |
| 33 | + EXPECTED_INSTALLATION_ID: ${{ vars.SDK_SENTINEL_RELAY_INSTALLATION_ID }} |
| 34 | + run: | |
| 35 | + test "$ACTUAL_APP_SLUG" = sdk-sentinel-relay |
| 36 | + test "$ACTUAL_INSTALLATION_ID" = "$EXPECTED_INSTALLATION_ID" |
| 37 | + - name: Dispatch the trusted central responder |
| 38 | + env: |
| 39 | + COMMENT_ID: ${{ github.event.comment.id }} |
| 40 | + DISPATCH_TOKEN: ${{ steps.dispatch-token.outputs.token }} |
| 41 | + PR_NUMBER: ${{ github.event.issue.number }} |
| 42 | + TARGET_ID: java |
| 43 | + run: | |
| 44 | + payload="$( |
| 45 | + jq -cn \ |
| 46 | + --arg target "$TARGET_ID" \ |
| 47 | + --arg pr_number "$PR_NUMBER" \ |
| 48 | + --arg comment_id "$COMMENT_ID" \ |
| 49 | + '{ref:"main",inputs:{target:$target,pr_number:$pr_number,comment_id:$comment_id}}' |
| 50 | + )" |
| 51 | + curl --fail --silent --show-error \ |
| 52 | + --request POST \ |
| 53 | + --header "Accept: application/vnd.github+json" \ |
| 54 | + --header "Authorization: Bearer $DISPATCH_TOKEN" \ |
| 55 | + --header "X-GitHub-Api-Version: 2022-11-28" \ |
| 56 | + --data "$payload" \ |
| 57 | + https://api.github.com/repos/temporalio/sdk-sentinel/actions/workflows/sdk-pr-responder.yml/dispatches |
0 commit comments