Skip to content

Commit 3d95c02

Browse files
committed
perf: add outputs to tf_plan_apply
1 parent 4fa7938 commit 3d95c02

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/tf_plan_apply.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
description: 'Runner JSON string'
88
default: '"ubuntu-latest"'
99
type: string
10+
outputs:
11+
tf_plan_exit_code:
12+
description: 'OpenTofu Plan exit code'
13+
value: ${{ jobs.tofu-plan.outputs.tf_plan_exit_code }}
14+
tf_destroy:
15+
description: 'Destroy flag'
16+
value: ${{ jobs.tofu-plan.outputs.tf_destroy }}
1017

1118
# Special permissions required for OIDC authentication
1219
permissions:
@@ -29,7 +36,8 @@ jobs:
2936
ARM_USE_OIDC: true
3037
TF_DESTROY: "${{ vars.TF_DESTROY }}"
3138
outputs:
32-
tf-plan-exit-code: ${{ steps.tf-plan.outputs.exitcode }}
39+
tf_plan_exit_code: ${{ steps.tf-plan.outputs.exitcode }}
40+
tf_destroy: ${{ steps.tf-plan.outputs.tf_destroy }}
3341

3442
steps:
3543
# Checkout the repository to the GitHub Actions runner
@@ -68,6 +76,7 @@ jobs:
6876
-out tfplan || export exitcode=$?
6977
7078
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
79+
echo "tf_destroy=${{ env.TF_DESTROY }}" >> $GITHUB_OUTPUT
7180
7281
if [ $exitcode -eq 1 ]; then
7382
echo OpenTofu Plan Failed!
@@ -87,7 +96,7 @@ jobs:
8796
tofu-apply:
8897
name: 'OpenTofu Apply'
8998
needs: [tofu-plan]
90-
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.tofu-plan.outputs.tf-plan-exit-code == 2 }}
99+
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.tofu-plan.outputs.tf_plan_exit_code == 2 }}
91100
runs-on: ${{ fromJSON(inputs.runs_on) }}
92101
environment: ${{ github.ref_name }}
93102
env:

0 commit comments

Comments
 (0)