getsentry-dispatch.js 1.6 KB

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