()
| 38 | const { version: appVersion } = require('../package.json'); |
| 39 | |
| 40 | export async function run(): Promise<void> { |
| 41 | // Note: unlike the other actions, we actually want to export this as a |
| 42 | // persistent variable for future steps. Other actions should set process.env |
| 43 | // or use stubEnv to only set metrics for the duration of the step. |
| 44 | core.exportVariable('CLOUDSDK_METRICS_ENVIRONMENT', 'github-actions-setup-gcloud'); |
| 45 | core.exportVariable('CLOUDSDK_METRICS_ENVIRONMENT_VERSION', appVersion); |
| 46 | |
| 47 | process.env.CLOUDSDK_CORE_DISABLE_PROMPTS = '1'; |
| 48 | |
| 49 | // Warn if pinned to HEAD |
| 50 | if (isPinnedToHead()) { |
| 51 | core.warning(pinnedToHeadWarning('v3')); |
| 52 | } |
| 53 | |
| 54 | try { |
| 55 | const skipInstall = parseBoolean(core.getInput('skip_install')); |
| 56 | let version = presence(core.getInput('version')); |
| 57 | const components = core.getInput('install_components'); |
| 58 | const projectId = core.getInput('project_id'); |
| 59 | const cache = parseBoolean(core.getInput('cache')); |
| 60 | |
| 61 | if (skipInstall) { |
| 62 | core.info(`Skipping installation ("skip_install" was true)`); |
| 63 | if (version && version !== 'latest') { |
| 64 | core.warning(`Ignoring "version" because "skip_install" was true!`); |
| 65 | } |
| 66 | |
| 67 | if (components) { |
| 68 | core.warning( |
| 69 | `Installing custom components with the system-provided gcloud may fail. ` + |
| 70 | `Set "skip_install" to false to install a managed version.`, |
| 71 | ); |
| 72 | } |
| 73 | } else { |
| 74 | // Compute the version information. If the version was not specified, |
| 75 | // accept any installed version. If the version was specified as "latest", |
| 76 | // compute the latest version. Otherwise, accept the version/version |
| 77 | // constraint as-is. |
| 78 | if (!version) { |
| 79 | core.debug(`version was unset, defaulting to any version`); |
| 80 | version = '> 0.0.0'; |
| 81 | } |
| 82 | if (version === 'latest') { |
| 83 | core.debug(`resolving latest version`); |
| 84 | version = await bestVersion('> 0.0.0'); |
| 85 | core.debug(`resolved latest version to ${version}`); |
| 86 | } |
| 87 | |
| 88 | // Install the gcloud if not already present |
| 89 | const toolPath = toolCache.find('gcloud', version); |
| 90 | if (toolPath !== '') { |
| 91 | core.addPath(path.join(toolPath, 'bin')); |
| 92 | } else { |
| 93 | core.debug(`no version of gcloud matching "${version}" is installed`); |
| 94 | await installGcloudSDK(version, cache); |
| 95 | } |
| 96 | } |
| 97 |
no outgoing calls
no test coverage detected