getsentry-dispatch.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Dispatch a request to getsentry to run getsentry test suites
  2. name: getsentry dispatcher
  3. on:
  4. # XXX: We are using `pull_request_target` instead of `pull_request` because we want
  5. # this to run on forks. It allows forks to access secrets safely by
  6. # only running workflows from the main branch. Prefer to use `pull_request` when possible.
  7. #
  8. # See https://github.com/getsentry/sentry/pull/21600 for more details
  9. pull_request_target:
  10. types: [labeled, opened, reopened, synchronize]
  11. # disable all other special privileges
  12. permissions:
  13. # needed for `actions/checkout` to clone the code
  14. contents: read
  15. # needed to remove the pull-request label
  16. pull-requests: write
  17. jobs:
  18. dispatch:
  19. if: "github.event.action != 'labeled' || github.event.label.name == 'Trigger: getsentry tests'"
  20. name: getsentry dispatch
  21. runs-on: ubuntu-20.04
  22. steps:
  23. - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  24. with:
  25. persist-credentials: false
  26. - name: permissions
  27. run: |
  28. python3 -uS .github/workflows/scripts/getsentry-dispatch-setup \
  29. --repo-id ${{ github.event.repository.id }} \
  30. --pr ${{ github.event.number }} \
  31. --event ${{ github.event.action }} \
  32. --username "$ARG_USERNAME" \
  33. --label-names "$ARG_LABEL_NAMES"
  34. env:
  35. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  36. # these can contain special characters
  37. ARG_USERNAME: ${{ github.event.pull_request.user.login }}
  38. ARG_LABEL_NAMES: ${{ toJSON(github.event.pull_request.labels.*.name) }}
  39. - name: Check for file changes
  40. uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
  41. id: changes
  42. with:
  43. token: ${{ github.token }}
  44. filters: .github/file-filters.yml
  45. - name: getsentry token
  46. uses: getsentry/action-github-app-token@97c9e23528286821f97fba885c1b1123284b29cc # v2.0.0
  47. id: getsentry
  48. with:
  49. app_id: ${{ secrets.SENTRY_INTERNAL_APP_ID }}
  50. private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
  51. - name: Wait for PR merge commit
  52. uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
  53. id: mergecommit
  54. with:
  55. github-token: ${{ steps.getsentry.outputs.token }}
  56. script: |
  57. require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/wait-for-merge-commit`).waitForMergeCommit({
  58. github,
  59. context,
  60. core,
  61. });
  62. - name: Dispatch getsentry tests
  63. uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
  64. with:
  65. github-token: ${{ steps.getsentry.outputs.token }}
  66. script: |
  67. require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/getsentry-dispatch`).dispatch({
  68. github,
  69. context,
  70. core,
  71. mergeCommitSha: '${{ steps.mergecommit.outputs.mergeCommitSha }}',
  72. fileChanges: ${{ toJson(steps.changes.outputs) }},
  73. });