Skip to content

Instantly share code, notes, and snippets.

@geekzter
Last active January 19, 2024 16:37
Show Gist options
  • Select an option

  • Save geekzter/4f71f3eda784bb66e5680e019bc1e56d to your computer and use it in GitHub Desktop.

Select an option

Save geekzter/4f71f3eda784bb66e5680e019bc1e56d to your computer and use it in GitHub Desktop.
Export Terraform output as GitHub Action step output
- name: Terraform Apply
id: terraform-apply
run: |
Set-Location (Join-Path $env:GITHUB_WORKSPACE terraform) # Task does not support 'working-directory' property
terraform apply -auto-approve
# Export Terraform output as step output
$terraformOutput = (terraform output -json | ConvertFrom-Json -AsHashtable)
foreach ($key in $terraformOutput.Keys) {
$outputVariableValue = $terraformOutput[$key].value
Write-Output "::set-output name=${key}::${outputVariableValue}"
Write-Output "TF_OUT_${key}=${outputVariableValue}" >> $env:GITHUB_ENV
}
shell: pwsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment