-
Notifications
You must be signed in to change notification settings - Fork 233
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
Output selected terraform version #326
Comments
@F21 Hi! Is this what you mean? It does not seem necessary to create output in setup-terraform. |
@officel According to https://github.com/hashicorp/setup-terraform?tab=readme-ov-file#inputs, we can use semver to select the terraform version, so we don't know the version that will be installed before hand. If we can access the final version that was selected, we would be able to use it in other steps. |
Seems like there is no need to output it in the setup-terrafom since we can always use the latest or a fixed version? But.. so.. if you just want to get the version, you can do it in just a few lines. cat .github/workflows/terraform_version.yml
name: terraform version
on:
workflow_dispatch:
jobs:
tv:
runs-on: ubuntu-latest
strategy:
matrix:
versions:
- "latest"
- "1.4"
- "1.1"
outputs:
version: ${{ steps.terraform_version.outputs.version }}
steps:
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.versions }}
- id: terraform_version
run: |
echo $(terraform-bin version -json | jq -r ".terraform_version")
echo "version=" $(terraform-bin version -json | jq -r ".terraform_version") >> "$GITHUB_OUTPUT"
|
That works! Thanks 😄 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
It would be nice if the version of terraform that is installed can be set as an output variable, so that it can be used by other steps in a workflow.
This would be especially useful when semver is used to select a version of terraform, for example, if
terraform_version
is set to~1.4
, and the output would contain the version that is ultimately selected, such as1.4.6
.The text was updated successfully, but these errors were encountered: