1- name : Test terraform-binary- plan
1+ name : Test terraform-plan using binary plan
22
33on :
44 - pull_request
55
6+ permissions :
7+ contents : read
8+
69jobs :
710 missing_plan_path :
8- runs-on : ubuntu-latest
11+ runs-on : ubuntu-24.04
912 name : Missing plan
1013 steps :
1114 - name : Checkout
1215 uses : actions/checkout@v4
16+ with :
17+ persist-credentials : false
1318
1419 - name : Apply
1520 uses : ./terraform-apply
@@ -21,20 +26,27 @@ jobs:
2126 auto_approve : true
2227
2328 - name : Verify outputs
29+ env :
30+ OUTCOME : ${{ steps.apply.outcome }}
2431 run : |
25- if [[ "${{ steps.apply.outcome }} " != "failure" ]]; then
32+ if [[ "$OUTCOME " != "failure" ]]; then
2633 echo "Apply did not fail correctly"
2734 exit 1
2835 fi
2936
3037 apply :
31- runs-on : ubuntu-latest
38+ runs-on : ubuntu-24.04
3239 name : Apply approved changes
40+ permissions :
41+ contents : read
42+ pull-requests : write
3343 env :
3444 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3545 steps :
3646 - name : Checkout
3747 uses : actions/checkout@v4
48+ with :
49+ persist-credentials : false
3850
3951 - name : Plan
4052 uses : ./terraform-plan
@@ -52,11 +64,13 @@ jobs:
5264 plan_path : ${{ steps.plan.outputs.plan_path }}
5365
5466 auto_approve :
55- runs-on : ubuntu-latest
67+ runs-on : ubuntu-24.04
5668 name : Apply auto approved changes
5769 steps :
5870 - name : Checkout
5971 uses : actions/checkout@v4
72+ with :
73+ persist-credentials : false
6074
6175 - name : Plan
6276 uses : ./terraform-plan
@@ -75,13 +89,18 @@ jobs:
7589 auto_approve : true
7690
7791 plan_changed :
78- runs-on : ubuntu-latest
92+ runs-on : ubuntu-24.04
7993 name : Apply should fail if the approved plan has changed
94+ permissions :
95+ contents : read
96+ pull-requests : write
8097 env :
8198 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8299 steps :
83100 - name : Checkout
84101 uses : actions/checkout@v4
102+ with :
103+ persist-credentials : false
85104
86105 - name : Plan
87106 uses : ./terraform-plan
@@ -106,13 +125,16 @@ jobs:
106125 plan_path : ${{ steps.plan.outputs.plan_path }}
107126
108127 - name : Verify outputs
128+ env :
129+ OUTCOME : ${{ steps.apply.outcome }}
130+ FAILURE_REASON : ${{ steps.apply.outputs.failure-reason }}
109131 run : |
110- if [[ "${{ steps.apply.outcome }} " != "failure" ]]; then
132+ if [[ "$OUTCOME " != "failure" ]]; then
111133 echo "Apply did not fail correctly"
112134 exit 1
113135 fi
114136
115- if [[ "${{ steps.apply.outputs.failure-reason }} " != "plan-changed" ]]; then
137+ if [[ "$FAILURE_REASON " != "plan-changed" ]]; then
116138 echo "::error:: failure-reason not set correctly"
117139 exit 1
118140 fi
0 commit comments