getsentry-dispatch.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * List of workflows to dispatch to `getsentry`
  3. *
  4. * `pathFilterName` refers to the path filters in `.github/file-filters.yml` (`getsentry/paths-filter` action)
  5. *
  6. * TODO(billy): Refactor workflow files to be an enum so that we can integration test them. Otherwise if they are
  7. * deleted/renamed in `getsentry`, this will fail
  8. */
  9. const DISPATCHES = [
  10. {
  11. workflow: 'js-build-and-lint.yml',
  12. pathFilterName: 'frontend_all',
  13. },
  14. {
  15. workflow: 'backend.yml',
  16. pathFilterName: 'backend_all',
  17. },
  18. ];
  19. module.exports = {
  20. dispatch: async ({github, context, core, fileChanges, mergeCommitSha}) => {
  21. core.startGroup('Dispatching request to getsentry.');
  22. await Promise.all(
  23. DISPATCHES.map(({workflow, pathFilterName}) => {
  24. const inputs = {
  25. pull_request_number: `${context.payload.pull_request.number}`, // needs to be string
  26. skip: `${fileChanges[pathFilterName] !== 'true'}`, // even though this is a boolean, it must be cast to a string
  27. // sentrySHA is the sha getsentry should run against.
  28. 'sentry-sha': mergeCommitSha,
  29. // prSHA is the sha actions should post commit statuses too.
  30. 'sentry-pr-sha': context.payload.pull_request.head.sha,
  31. };
  32. core.info(
  33. `Sending dispatch for '${workflow}':\n${JSON.stringify(inputs, null, 2)}`
  34. );
  35. return github.rest.actions.createWorkflowDispatch({
  36. owner: 'getsentry',
  37. repo: 'getsentry',
  38. workflow_id: workflow,
  39. ref: 'master',
  40. inputs,
  41. });
  42. })
  43. );
  44. core.endGroup();
  45. },
  46. };