getsentry-dispatch.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 !== 'true',
  24. backend_dependencies: fileChanges.backend_dependencies !== 'true',
  25. };
  26. DISPATCHES.forEach(({workflow, pathFilterName}) => {
  27. github.actions.createWorkflowDispatch({
  28. owner: 'getsentry',
  29. repo: 'getsentry',
  30. workflow_id: workflow,
  31. ref: 'master',
  32. inputs: {
  33. pull_request_number: `${context.payload.pull_request.number}`, // needs to be string
  34. skip: `${shouldSkip[pathFilterName]}`, // even though this is a boolean, it must be cast to a string
  35. 'sentry-sha': context.payload.pull_request.head.sha,
  36. },
  37. });
  38. });
  39. },
  40. };