@actions/core
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -99,1 +99,15 @@ /** | ||
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>; | ||
/** | ||
* 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 declare function saveState(name: string, value: string): void; | ||
/** | ||
* Gets the value of an state set by this action's main execution. | ||
* | ||
* @param name name of the state to get | ||
* @returns string | ||
*/ | ||
export declare function getState(name: string): string; |
@@ -172,2 +172,25 @@ "use strict"; | ||
exports.group = group; | ||
//----------------------------------------------------------------------- | ||
// 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 | ||
*/ | ||
function saveState(name, value) { | ||
command_1.issueCommand('save-state', { name }, value); | ||
} | ||
exports.saveState = saveState; | ||
/** | ||
* Gets the value of an state set by this action's main execution. | ||
* | ||
* @param name name of the state to get | ||
* @returns string | ||
*/ | ||
function getState(name) { | ||
return process.env[`STATE_${name}`] || ''; | ||
} | ||
exports.getState = getState; | ||
//# sourceMappingURL=core.js.map |
{ | ||
"name": "@actions/core", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Actions core lib", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -107,2 +107,35 @@ # `@actions/core` | ||
}) | ||
``` | ||
#### Action state | ||
You can use this library to save state and get state for sharing information between a given wrapper action: | ||
**action.yml** | ||
```yaml | ||
name: 'Wrapper action sample' | ||
inputs: | ||
name: | ||
default: 'GitHub' | ||
runs: | ||
using: 'node12' | ||
main: 'main.js' | ||
post: 'cleanup.js' | ||
``` | ||
In action's `main.js`: | ||
```js | ||
const core = require('@actions/core'); | ||
core.saveState("pidToKill", 12345); | ||
``` | ||
In action's `cleanup.js`: | ||
```js | ||
const core = require('@actions/core'); | ||
var pid = core.getState("pidToKill"); | ||
process.kill(pid); | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20107
387
140
5