deploy.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* eslint-env node */
  2. /**
  3. * GHA Workflow helpers for deploys
  4. *
  5. */
  6. module.exports = {
  7. /**
  8. * Checks what files were changed in a commit and adds a GH check
  9. * corresponding with changes. This can be used by our deploy system to
  10. * determine what Freight deploy we can use.
  11. */
  12. updateChangeType: async ({github, context, fileChanges}) => {
  13. // Note that `fileChanges` bools and ints will get cast to strings
  14. const {frontend_all: frontend, backend_all: backend} = fileChanges;
  15. const frontendOnly = frontend === 'true' && backend === 'false';
  16. const backendOnly = backend === 'true' && frontend === 'false';
  17. const name = frontendOnly
  18. ? 'only frontend changes'
  19. : backendOnly
  20. ? 'only backend changes'
  21. : 'fullstack changes';
  22. if (!name) {
  23. return null;
  24. }
  25. const result = await github.rest.checks.create({
  26. owner: context.repo.owner,
  27. repo: context.repo.repo,
  28. name,
  29. head_sha: context.sha,
  30. status: 'completed',
  31. conclusion: 'success',
  32. });
  33. return result;
  34. },
  35. };