mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-12-01 04:04:28 +01:00
Add OpenTofu version file support (#59)
Signed-off-by: Brendon Smith <bws@bws.bio>
This commit is contained in:
1 parent
4a98c1282d
commit
000eeb8522
7 files changed
+258
-2
No files matched your search
+23
-1
@@ -128,7 +128,8 @@ credentials "${credentialsHostname}" {
|
||||
async function run () {
|
||||
try {
|
||||
// Gather GitHub Actions inputs
|
||||
const version = core.getInput('tofu_version');
|
||||
let version = core.getInput('tofu_version');
|
||||
const versionFile = core.getInput('tofu_version_file');
|
||||
const credentialsHostname = core.getInput('cli_config_credentials_hostname');
|
||||
const credentialsToken = core.getInput('cli_config_credentials_token');
|
||||
const wrapper = core.getInput('tofu_wrapper') === 'true';
|
||||
@@ -139,6 +140,27 @@ async function run () {
|
||||
githubToken = process.env.GITHUB_TOKEN;
|
||||
}
|
||||
|
||||
// If tofu_version_file is provided, read the version from the file
|
||||
if (versionFile) {
|
||||
try {
|
||||
core.debug(`Reading OpenTofu version from file: ${versionFile}`);
|
||||
const fileVersion = await fs.readFile(versionFile, 'utf8');
|
||||
const trimmedVersion = fileVersion.trim();
|
||||
if (trimmedVersion) {
|
||||
version = trimmedVersion;
|
||||
core.debug(`Using version from file: ${version}`);
|
||||
} else {
|
||||
core.warning(
|
||||
`Version file ${versionFile} is empty, using tofu_version input: ${version}`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
core.warning(
|
||||
`Failed to read version from file ${versionFile}: ${error.message}. Using tofu_version input: ${version}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Gather OS details
|
||||
const osPlatform = os.platform();
|
||||
const osArch = os.arch();
|
||||
|
||||
Reference in new issue
Block a user