Merge pull request #149 from actions/users/tihuang/statecommand

add core method to saveState and getState.
This commit is contained in:
Josh Gross authored and GitHub committed 2019-10-10 20:04:39 -04:00
commit fa4619c3e0
3 files changed
+70 -1

No files matched your search

+24
View File
@@ -173,3 +173,27 @@ export async function group<T>(name: string, fn: () => Promise<T>): Promise<T> {
return result
}
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
/**
* Saves state for current action, the state can only be retrieved by this action's post job execution.
*
* @param name name of the state to store
* @param value value to store
*/
export function saveState(name: string, value: string): void {
issueCommand('save-state', {name}, value)
}
/**
* Gets the value of an state set by this action's main execution.
*
* @param name name of the state to get
* @returns string
*/
export function getState(name: string): string {
return process.env[`STATE_${name}`] || ''
}