Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action.yml #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `scalr-action` action is an action written in JavaScript that sets up the Scalr and Terraform CLI. The action does the following:

- Downloads (and caching) the latest version of [Scalr CLI](https://github.com/Scalr/scalr-cli) and adds it to the `PATH`.
- Downloads (and caching) a specific (or latest) version of [Scalr CLI](https://github.com/Scalr/scalr-cli) and adds it to the `PATH`.
- Dowloads (and caching) a specific (or autodetected) version of Terraform CLI and adds it to the `PATH`.
- Configures the Scalr CLI and [Terraform CLI configuration file](https://www.terraform.io/docs/commands/cli-config.html) with a Scalr Hostname and Token.
- Optionally: Installs a script to wrap following calls of the `terraform` binary. Exposes the STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode`. Enabled by default
Expand Down Expand Up @@ -76,6 +76,8 @@ The action supports the following inputs:

- `scalr_workspace` - The Scalr workspace ID you plan on working in. This is required if you want to auto-detect Terraform version.

- `scalr_cli_version` - The version of Scalr CLI. The latest version will be used if this is not specified.

- `terraform_version` - The version of Terraform CLI. This must match the version set in your Scalr Workspace. It will be autodetected if left empty and workspace is set.

- `terraform_wrapper` - Whether or not to install a wrapper to wrap calls of the `terraform` binary and expose its STDOUT, STDERR, and exit code
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
scalr_workspace:
description: 'The Scalr workspace ID you plan on working in. This is required if you want to autodetect Terraform version.'
required: false
scalr_cli_version:
description: 'The Scalr CLI version to install. Defaults to the latest.'
required: false
terraform_version:
description: 'The version of Terraform CLI to install. Should match the version set in your Scalr Workspace. Will be autodetected if left empty and workspace is set.'
required: false
Expand Down
14 changes: 9 additions & 5 deletions src/terraform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ const { stdout } = require('process');
const hostname = core.getInput('scalr_hostname', { required: true })
const token = core.getInput('scalr_token', { required: true })
const workspace = core.getInput('scalr_workspace')
let cli_version = core.getInput('scalr_cli_version')
let version = core.getInput('terraform_version')
const wrapper = core.getInput('terraform_wrapper') === 'true';
const output = core.getInput('terraform_output')

const platform = {'win32':'windows'}[os.platform()] || os.platform()
const arch = {'x32':'386', 'x64':'amd64'}[os.arch()] || os.arch()

core.info('Fetch latest version of Scalr CLI')
let latest = await axios.head('https://github.com/scalr/scalr-cli/releases/latest')
let ver = new URL(latest.request.res.responseUrl).pathname.split('/').pop().replace('v', '');
let url = `https://github.com/Scalr/scalr-cli/releases/download/v${ver}/scalr-cli_${ver}_${platform}_${arch}.zip`
if (!cli_version) {
core.info('Fetch latest version of Scalr CLI')
let latest = await axios.head('https://github.com/scalr/scalr-cli/releases/latest')
cli_version = new URL(latest.request.res.responseUrl).pathname.split('/').pop();
}
cli_version = cli_version.replace('v', '');
let url = `https://github.com/Scalr/scalr-cli/releases/download/v${cli_version}/scalr-cli_${cli_version}_${platform}_${arch}.zip`

core.info(`Downloading compressed Scalr CLI binary from ${url}`)
const zip2 = await toolcache.downloadTool(url)
Expand Down Expand Up @@ -103,4 +107,4 @@ const { stdout } = require('process');

} catch(error) {
core.setFailed(error.message)
} })();
} })();