getsentry-dispatch.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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',
  14. },
  15. {
  16. workflow: 'backend.yml',
  17. pathFilterName: 'backend_dependencies',
  18. },
  19. ];
  20. module.exports = {
  21. dispatch: async ({github, context, fileChanges}) => {
  22. const shouldSkip = {
  23. frontend: fileChanges.frontend_all !== 'true',
  24. backend_dependencies: fileChanges.backend_dependencies !== 'true',
  25. };
  26. await Promise.all(
  27. DISPATCHES.map(({workflow, pathFilterName}) => {
  28. return github.actions.createWorkflowDispatch({
  29. owner: 'getsentry',
  30. repo: 'getsentry',
  31. workflow_id: workflow,
  32. ref: 'master',
  33. inputs: {
  34. pull_request_number: `${context.payload.pull_request.number}`, // needs to be string
  35. skip: `${shouldSkip[pathFilterName]}`, // even though this is a boolean, it must be cast to a string
  36. 'sentry-sha': context.payload.pull_request.head.sha,
  37. },
  38. });
  39. })
  40. );
  41. },
  42. };