Last active
January 19, 2024 16:37
-
-
Save geekzter/4f71f3eda784bb66e5680e019bc1e56d to your computer and use it in GitHub Desktop.
Export Terraform output as GitHub Action step output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - 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