state-helper.ts 846 B

1234567891011121314151617181920212223242526272829
  1. import * as coreCommand from '@actions/core/lib/command'
  2. /**
  3. * Indicates whether the POST action is running
  4. */
  5. export const IsPost = !!process.env['STATE_isPost']
  6. /**
  7. * The repository path for the POST action. The value is empty during the MAIN action.
  8. */
  9. export const RepositoryPath =
  10. (process.env['STATE_repositoryPath'] as string) || ''
  11. /**
  12. * Save the repository path so the POST action can retrieve the value.
  13. */
  14. export function setRepositoryPath(repositoryPath: string) {
  15. coreCommand.issueCommand(
  16. 'save-state',
  17. {name: 'repositoryPath'},
  18. repositoryPath
  19. )
  20. }
  21. // Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
  22. // This is necessary since we don't have a separate entry point.
  23. if (!IsPost) {
  24. coreCommand.issueCommand('save-state', {name: 'isPost'}, 'true')
  25. }