Ability to use latest Terraform version rather than hard coding tf_actions_version
EddieOX opened this issue · comments
Hello,
Before v0.5.0 you had to update the Terraform version in these actions. Now the end user needs to update the Terraform version. Is it possible to add a feature to just use latest Terraform version? We are using Terraform Cloud with workspaces set to "latest" version. It's difficult to time a change to "tf_actions_version", in a large amount of repositories, with the Terraform releases.
Thanks
Hi @EddieOX
It's only FYI.
- Short answer is No.
see: https://github.com/hashicorp/terraform-github-actions/blob/master/src/main.sh#L47
"latest" directory is none on releases.hashicorp.com/terraform/
maybe can use hashicorp/terraform:latest image. tfenv, or others.
but now so not...
- Alt answer is Yes.
Of course I have many projects, repositories and versions.
I think don't wrote "tf_actions_version" literal some times too.
So I try to sometimes...
see:
name: pr_tf
on:
pull_request:
env:
TF_ACTIONS_VERSION: 0.12.13
jobs:
on-pull-request:
name: terraform
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Terraform - Format
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: ${{ env.TF_ACTIONS_VERSION }}
tf_actions_subcommand: 'fmt'
- name: Terraform - Init
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: ${{ env.TF_ACTIONS_VERSION }}
tf_actions_subcommand: 'init'
ommit
so looks env use re-cycle workflow.yaml.
Write only one time.
nnnn, It's not cool?... 😢
- other answer use secrets.
with:
tf_actions_version: ${{ secrets.TF_ACTIONS_VERSION }}
perhaps if all tf directory only one version in repository, maybe cool.
- Great answer
maybe great answer is fix action.yml.
here not require and default version set.
BTW. I think "tf_actions_subcommand" 's default value is "fmt" is good.
It's zero configurations is good.
That's ALL.
This is what I came up with to solve my problem:
name: 'Terraform Pull Request Workflow'
on:
- pull_request
jobs:
main:
name: 'Terraform Actions'
timeout-minutes: 3
runs-on: ubuntu-latest
steps:
- name: 'Get latest Terraform GitHub release and remove "v" from tag name for version'
run: "echo ::set-output name=tf_actions_version::$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | jq -r '.tag_name' | sed 's/^v//')"
shell: bash
id: get_tf_latest
- name: 'GitHub Checkout'
uses: actions/checkout@master
- name: 'Fmt Check'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: ${{ steps.get_tf_latest.outputs.tf_actions_version }}
tf_actions_subcommand: 'fmt'
tf_actions_working_dir: '.'
tf_actions_comment: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Released in v0.6.4.