js-getsentry-dispatch.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # If frontend files change, dispatch a request to getsentry to run its javascript 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. jobs:
  11. frontend:
  12. name: frontend dispatch
  13. runs-on: ubuntu-16.04
  14. steps:
  15. # Need to checkout just for `github/file-filters.yml`
  16. - uses: actions/checkout@v2
  17. - name: Check for frontend file changes
  18. uses: getsentry/paths-filter@v2
  19. id: changes
  20. with:
  21. token: ${{ github.token }}
  22. filters: .github/file-filters.yml
  23. - name: getsentry token
  24. uses: getsentry/action-github-app-token@v1
  25. id: getsentry
  26. with:
  27. app_id: ${{ secrets.SENTRY_INTERNAL_APP_ID }}
  28. private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
  29. - name: Dispatch getsentry frontend tests
  30. uses: actions/github-script@v3
  31. with:
  32. github-token: ${{ steps.getsentry.outputs.token }}
  33. script: |
  34. // Check for getsentry PR dependency
  35. const body = context.payload.pull_request.body;
  36. // Logs convert the full PR URL into a shortened link, but we need to match against the full URL
  37. const matches = body && body.match(/requires.*getsentry\/getsentry\/pull\/(\d+)/im);
  38. const pr = matches && await github.pulls.get({
  39. owner: 'getsentry',
  40. repo: 'getsentry',
  41. pull_number: matches[1],
  42. });
  43. const branch = pr ? pr.data.head.ref : '';
  44. github.actions.createWorkflowDispatch({
  45. owner: 'getsentry',
  46. repo: 'getsentry',
  47. workflow_id: 'js-build-and-lint.yml',
  48. ref: 'master',
  49. inputs: {
  50. pull_request: matches && matches[1] || '',
  51. branch,
  52. skip: "${{ steps.changes.outputs.frontend != 'true' }}",
  53. 'sentry-sha': '${{ github.event.pull_request.head.sha }}',
  54. }
  55. })