sentry-pull-request-bot.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: sentry pull request bot
  2. # Note this event happens on Issue comments AND PR comments,
  3. # we make sure that we only respond to PR comments.
  4. on:
  5. issue_comment:
  6. types: [created, edited]
  7. pull_request:
  8. types: [opened, edited]
  9. jobs:
  10. # TODO(billy): Move this into an external action as we add more functionality
  11. test-getsentry:
  12. name: test getsentry
  13. runs-on: ubuntu-20.04
  14. # Ensure this bot only responds for pull requests and only for the main repository
  15. if: >-
  16. (github.event.issue.pull_request.url != '' || github.event.pull_request.id != '') &&
  17. (contains(github.event.comment.body, '#test-getsentry') || contains(github.event.pull_request.body, '#test-getsentry')) &&
  18. github.repository == 'getsentry/sentry'
  19. steps:
  20. - name: Check getsentry membership
  21. id: org
  22. uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
  23. with:
  24. script: |
  25. try {
  26. const result = await github.rest.orgs.checkMembershipForUser({
  27. org: 'getsentry',
  28. username: context.payload.sender.login,
  29. })
  30. return result.status == 204;
  31. } catch {
  32. return false;
  33. }
  34. - name: Fetch getsentry token
  35. if: steps.org.outputs.result == 'true'
  36. id: getsentry
  37. uses: getsentry/action-github-app-token@97c9e23528286821f97fba885c1b1123284b29cc # v2.0.0
  38. with:
  39. app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }}
  40. private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
  41. - name: Wait for PR merge commit
  42. uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
  43. id: mergecommit
  44. with:
  45. github-token: ${{ steps.getsentry.outputs.token }}
  46. script: |
  47. require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/wait-for-merge-commit`).waitForMergeCommit({
  48. github,
  49. context,
  50. core,
  51. });
  52. - name: Dispatch getsentry tests
  53. if: steps.org.outputs.result == 'true'
  54. uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
  55. with:
  56. github-token: ${{ steps.getsentry.outputs.token }}
  57. script: |
  58. github.rest.actions.createWorkflowDispatch({
  59. owner: 'getsentry',
  60. repo: 'getsentry',
  61. workflow_id: 'acceptance.yml',
  62. ref: 'master',
  63. inputs: {
  64. 'sentry-sha': '${{ steps.mergecommit.outputs.mergeCommitSha }}',
  65. 'sentry-pr-sha': '${{ github.event.pull_request.head.sha }}',
  66. }
  67. })