1
0
Fork 0
mirror of https://github.com/actions/toolkit synced 2025-05-10 17:12:54 +00:00

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

add core method to saveState and getState.
This commit is contained in:
Josh Gross 2019-10-10 20:04:39 -04:00 committed by GitHub
commit e8d384d3af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 1 deletions

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}`] || ''
}