Backport state-helper updates

This commit is contained in:
Francesco Renzi 2022-10-13 16:32:02 +01:00
parent 85a223bd8d
commit 37a3a5ae07
2 changed files with 22 additions and 33 deletions

22
dist/index.js vendored
View file

@ -3975,59 +3975,59 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.setSafeDirectory = exports.setSshKnownHostsPath = exports.setSshKeyPath = exports.setRepositoryPath = exports.SshKnownHostsPath = exports.SshKeyPath = exports.PostSetSafeDirectory = exports.RepositoryPath = exports.IsPost = void 0; exports.setSafeDirectory = exports.setSshKnownHostsPath = exports.setSshKeyPath = exports.setRepositoryPath = exports.SshKnownHostsPath = exports.SshKeyPath = exports.PostSetSafeDirectory = exports.RepositoryPath = exports.IsPost = void 0;
const coreCommand = __importStar(__webpack_require__(431)); const core = __importStar(__webpack_require__(470));
/** /**
* Indicates whether the POST action is running * Indicates whether the POST action is running
*/ */
exports.IsPost = !!process.env['STATE_isPost']; exports.IsPost = !!core.getState('isPost');
/** /**
* The repository path for the POST action. The value is empty during the MAIN action. * The repository path for the POST action. The value is empty during the MAIN action.
*/ */
exports.RepositoryPath = process.env['STATE_repositoryPath'] || ''; exports.RepositoryPath = core.getState('repositoryPath');
/** /**
* The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action. * The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action.
*/ */
exports.PostSetSafeDirectory = process.env['STATE_setSafeDirectory'] === 'true'; exports.PostSetSafeDirectory = core.getState('setSafeDirectory') === 'true';
/** /**
* The SSH key path for the POST action. The value is empty during the MAIN action. * The SSH key path for the POST action. The value is empty during the MAIN action.
*/ */
exports.SshKeyPath = process.env['STATE_sshKeyPath'] || ''; exports.SshKeyPath = core.getState('sshKeyPath');
/** /**
* The SSH known hosts path for the POST action. The value is empty during the MAIN action. * The SSH known hosts path for the POST action. The value is empty during the MAIN action.
*/ */
exports.SshKnownHostsPath = process.env['STATE_sshKnownHostsPath'] || ''; exports.SshKnownHostsPath = core.getState('sshKnownHostsPath');
/** /**
* Save the repository path so the POST action can retrieve the value. * Save the repository path so the POST action can retrieve the value.
*/ */
function setRepositoryPath(repositoryPath) { function setRepositoryPath(repositoryPath) {
coreCommand.issueCommand('save-state', { name: 'repositoryPath' }, repositoryPath); core.saveState('repositoryPath', repositoryPath);
} }
exports.setRepositoryPath = setRepositoryPath; exports.setRepositoryPath = setRepositoryPath;
/** /**
* Save the SSH key path so the POST action can retrieve the value. * Save the SSH key path so the POST action can retrieve the value.
*/ */
function setSshKeyPath(sshKeyPath) { function setSshKeyPath(sshKeyPath) {
coreCommand.issueCommand('save-state', { name: 'sshKeyPath' }, sshKeyPath); core.saveState('sshKeyPath', sshKeyPath);
} }
exports.setSshKeyPath = setSshKeyPath; exports.setSshKeyPath = setSshKeyPath;
/** /**
* Save the SSH known hosts path so the POST action can retrieve the value. * Save the SSH known hosts path so the POST action can retrieve the value.
*/ */
function setSshKnownHostsPath(sshKnownHostsPath) { function setSshKnownHostsPath(sshKnownHostsPath) {
coreCommand.issueCommand('save-state', { name: 'sshKnownHostsPath' }, sshKnownHostsPath); core.saveState('sshKnownHostsPath', sshKnownHostsPath);
} }
exports.setSshKnownHostsPath = setSshKnownHostsPath; exports.setSshKnownHostsPath = setSshKnownHostsPath;
/** /**
* Save the sef-safe-directory input so the POST action can retrieve the value. * Save the sef-safe-directory input so the POST action can retrieve the value.
*/ */
function setSafeDirectory() { function setSafeDirectory() {
coreCommand.issueCommand('save-state', { name: 'setSafeDirectory' }, 'true'); core.saveState('setSafeDirectory', 'true');
} }
exports.setSafeDirectory = setSafeDirectory; exports.setSafeDirectory = setSafeDirectory;
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic. // Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
// This is necessary since we don't have a separate entry point. // This is necessary since we don't have a separate entry point.
if (!exports.IsPost) { if (!exports.IsPost) {
coreCommand.issueCommand('save-state', { name: 'isPost' }, 'true'); core.saveState('isPost', 'true');
} }

View file

@ -1,71 +1,60 @@
import * as coreCommand from '@actions/core/lib/command' import * as core from '@actions/core'
/** /**
* Indicates whether the POST action is running * Indicates whether the POST action is running
*/ */
export const IsPost = !!process.env['STATE_isPost'] export const IsPost = !!core.getState('isPost')
/** /**
* The repository path for the POST action. The value is empty during the MAIN action. * The repository path for the POST action. The value is empty during the MAIN action.
*/ */
export const RepositoryPath = export const RepositoryPath = core.getState('repositoryPath')
(process.env['STATE_repositoryPath'] as string) || ''
/** /**
* The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action. * The set-safe-directory for the POST action. The value is set if input: 'safe-directory' is set during the MAIN action.
*/ */
export const PostSetSafeDirectory = export const PostSetSafeDirectory = core.getState('setSafeDirectory') === 'true'
(process.env['STATE_setSafeDirectory'] as string) === 'true'
/** /**
* The SSH key path for the POST action. The value is empty during the MAIN action. * The SSH key path for the POST action. The value is empty during the MAIN action.
*/ */
export const SshKeyPath = (process.env['STATE_sshKeyPath'] as string) || '' export const SshKeyPath = core.getState('sshKeyPath')
/** /**
* The SSH known hosts path for the POST action. The value is empty during the MAIN action. * The SSH known hosts path for the POST action. The value is empty during the MAIN action.
*/ */
export const SshKnownHostsPath = export const SshKnownHostsPath = core.getState('sshKnownHostsPath')
(process.env['STATE_sshKnownHostsPath'] as string) || ''
/** /**
* Save the repository path so the POST action can retrieve the value. * Save the repository path so the POST action can retrieve the value.
*/ */
export function setRepositoryPath(repositoryPath: string) { export function setRepositoryPath(repositoryPath: string) {
coreCommand.issueCommand( core.saveState('repositoryPath', repositoryPath)
'save-state',
{name: 'repositoryPath'},
repositoryPath
)
} }
/** /**
* Save the SSH key path so the POST action can retrieve the value. * Save the SSH key path so the POST action can retrieve the value.
*/ */
export function setSshKeyPath(sshKeyPath: string) { export function setSshKeyPath(sshKeyPath: string) {
coreCommand.issueCommand('save-state', {name: 'sshKeyPath'}, sshKeyPath) core.saveState('sshKeyPath', sshKeyPath)
} }
/** /**
* Save the SSH known hosts path so the POST action can retrieve the value. * Save the SSH known hosts path so the POST action can retrieve the value.
*/ */
export function setSshKnownHostsPath(sshKnownHostsPath: string) { export function setSshKnownHostsPath(sshKnownHostsPath: string) {
coreCommand.issueCommand( core.saveState('sshKnownHostsPath', sshKnownHostsPath)
'save-state',
{name: 'sshKnownHostsPath'},
sshKnownHostsPath
)
} }
/** /**
* Save the sef-safe-directory input so the POST action can retrieve the value. * Save the sef-safe-directory input so the POST action can retrieve the value.
*/ */
export function setSafeDirectory() { export function setSafeDirectory() {
coreCommand.issueCommand('save-state', {name: 'setSafeDirectory'}, 'true') core.saveState('setSafeDirectory', 'true')
} }
// Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic. // Publish a variable so that when the POST action runs, it can determine it should run the cleanup logic.
// This is necessary since we don't have a separate entry point. // This is necessary since we don't have a separate entry point.
if (!IsPost) { if (!IsPost) {
coreCommand.issueCommand('save-state', {name: 'isPost'}, 'true') core.saveState('isPost', 'true')
} }