deploy.js 1.0 KB

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