Skip to content

Commit 37a3a5a

Browse files
committed
Backport state-helper updates
1 parent 85a223b commit 37a3a5a

File tree

2 files changed

+22
-33
lines changed

2 files changed

+22
-33
lines changed

dist/index.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -3975,59 +3975,59 @@ var __importStar = (this && this.__importStar) || function (mod) {
39753975
};
39763976
Object.defineProperty(exports, "__esModule", { value: true });
39773977
exports.setSafeDirectory = exports.setSshKnownHostsPath = exports.setSshKeyPath = exports.setRepositoryPath = exports.SshKnownHostsPath = exports.SshKeyPath = exports.PostSetSafeDirectory = exports.RepositoryPath = exports.IsPost = void 0;
3978-
const coreCommand = __importStar(__webpack_require__(431));
3978+
const core = __importStar(__webpack_require__(470));
39793979
/**
39803980
* Indicates whether the POST action is running
39813981
*/
3982-
exports.IsPost = !!process.env['STATE_isPost'];
3982+
exports.IsPost = !!core.getState('isPost');
39833983
/**
39843984
* The repository path for the POST action. The value is empty during the MAIN action.
39853985
*/
3986-
exports.RepositoryPath = process.env['STATE_repositoryPath'] || '';
3986+
exports.RepositoryPath = core.getState('repositoryPath');
39873987
/**
39883988
* The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action.
39893989
*/
3990-
exports.PostSetSafeDirectory = process.env['STATE_setSafeDirectory'] === 'true';
3990+
exports.PostSetSafeDirectory = core.getState('setSafeDirectory') === 'true';
39913991
/**
39923992
* The SSH key path for the POST action. The value is empty during the MAIN action.
39933993
*/
3994-
exports.SshKeyPath = process.env['STATE_sshKeyPath'] || '';
3994+
exports.SshKeyPath = core.getState('sshKeyPath');
39953995
/**
39963996
* The SSH known hosts path for the POST action. The value is empty during the MAIN action.
39973997
*/
3998-
exports.SshKnownHostsPath = process.env['STATE_sshKnownHostsPath'] || '';
3998+
exports.SshKnownHostsPath = core.getState('sshKnownHostsPath');
39993999
/**
40004000
* Save the repository path so the POST action can retrieve the value.
40014001
*/
40024002
function setRepositoryPath(repositoryPath) {
4003-
coreCommand.issueCommand('save-state', { name: 'repositoryPath' }, repositoryPath);
4003+
core.saveState('repositoryPath', repositoryPath);
40044004
}
40054005
exports.setRepositoryPath = setRepositoryPath;
40064006
/**
40074007
* Save the SSH key path so the POST action can retrieve the value.
40084008
*/
40094009
function setSshKeyPath(sshKeyPath) {
4010-
coreCommand.issueCommand('save-state', { name: 'sshKeyPath' }, sshKeyPath);
4010+
core.saveState('sshKeyPath', sshKeyPath);
40114011
}
40124012
exports.setSshKeyPath = setSshKeyPath;
40134013
/**
40144014
* Save the SSH known hosts path so the POST action can retrieve the value.
40154015
*/
40164016
function setSshKnownHostsPath(sshKnownHostsPath) {
4017-
coreCommand.issueCommand('save-state', { name: 'sshKnownHostsPath' }, sshKnownHostsPath);
4017+
core.saveState('sshKnownHostsPath', sshKnownHostsPath);
40184018
}
40194019
exports.setSshKnownHostsPath = setSshKnownHostsPath;
40204020
/**
40214021
* Save the sef-safe-directory input so the POST action can retrieve the value.
40224022
*/
40234023
function setSafeDirectory() {
4024-
coreCommand.issueCommand('save-state', { name: 'setSafeDirectory' }, 'true');
4024+
core.saveState('setSafeDirectory', 'true');
40254025
}
40264026
exports.setSafeDirectory = setSafeDirectory;
40274027
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
40284028
// This is necessary since we don't have a separate entry point.
40294029
if (!exports.IsPost) {
4030-
coreCommand.issueCommand('save-state', { name: 'isPost' }, 'true');
4030+
core.saveState('isPost', 'true');
40314031
}
40324032

40334033

src/state-helper.ts

+11-22
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,60 @@
1-
import * as coreCommand from '@actions/core/lib/command'
1+
import * as core from '@actions/core'
22

33
/**
44
* Indicates whether the POST action is running
55
*/
6-
export const IsPost = !!process.env['STATE_isPost']
6+
export const IsPost = !!core.getState('isPost')
77

88
/**
99
* The repository path for the POST action. The value is empty during the MAIN action.
1010
*/
11-
export const RepositoryPath =
12-
(process.env['STATE_repositoryPath'] as string) || ''
11+
export const RepositoryPath = core.getState('repositoryPath')
1312

1413
/**
1514
* The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action.
1615
*/
17-
export const PostSetSafeDirectory =
18-
(process.env['STATE_setSafeDirectory'] as string) === 'true'
16+
export const PostSetSafeDirectory = core.getState('setSafeDirectory') === 'true'
1917

2018
/**
2119
* The SSH key path for the POST action. The value is empty during the MAIN action.
2220
*/
23-
export const SshKeyPath = (process.env['STATE_sshKeyPath'] as string) || ''
21+
export const SshKeyPath = core.getState('sshKeyPath')
2422

2523
/**
2624
* The SSH known hosts path for the POST action. The value is empty during the MAIN action.
2725
*/
28-
export const SshKnownHostsPath =
29-
(process.env['STATE_sshKnownHostsPath'] as string) || ''
26+
export const SshKnownHostsPath = core.getState('sshKnownHostsPath')
3027

3128
/**
3229
* Save the repository path so the POST action can retrieve the value.
3330
*/
3431
export function setRepositoryPath(repositoryPath: string) {
35-
coreCommand.issueCommand(
36-
'save-state',
37-
{name: 'repositoryPath'},
38-
repositoryPath
39-
)
32+
core.saveState('repositoryPath', repositoryPath)
4033
}
4134

4235
/**
4336
* Save the SSH key path so the POST action can retrieve the value.
4437
*/
4538
export function setSshKeyPath(sshKeyPath: string) {
46-
coreCommand.issueCommand('save-state', {name: 'sshKeyPath'}, sshKeyPath)
39+
core.saveState('sshKeyPath', sshKeyPath)
4740
}
4841

4942
/**
5043
* Save the SSH known hosts path so the POST action can retrieve the value.
5144
*/
5245
export function setSshKnownHostsPath(sshKnownHostsPath: string) {
53-
coreCommand.issueCommand(
54-
'save-state',
55-
{name: 'sshKnownHostsPath'},
56-
sshKnownHostsPath
57-
)
46+
core.saveState('sshKnownHostsPath', sshKnownHostsPath)
5847
}
5948

6049
/**
6150
* Save the sef-safe-directory input so the POST action can retrieve the value.
6251
*/
6352
export function setSafeDirectory() {
64-
coreCommand.issueCommand('save-state', {name: 'setSafeDirectory'}, 'true')
53+
core.saveState('setSafeDirectory', 'true')
6554
}
6655

6756
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
6857
// This is necessary since we don't have a separate entry point.
6958
if (!IsPost) {
70-
coreCommand.issueCommand('save-state', {name: 'isPost'}, 'true')
59+
core.saveState('isPost', 'true')
7160
}

0 commit comments

Comments
 (0)