Skip to content

Commit f33cead

Browse files
committed
share tf plan in PR comment
1 parent 25cd1b6 commit f33cead

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

.github/workflows/aws-iac-prs.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ permissions:
1212
jobs:
1313
core_aws:
1414
outputs:
15-
tofu-plan-aws: ${{ steps.plan_output.outputs.output }}
16-
tofu-fmt-aws: ${{ steps.fmt_outcome.outputs.output }}
15+
plan: ${{ steps.plan_outcome.outputs.output }}
16+
fmt: ${{ steps.fmt_outcome.outputs.output }}
1717
defaults:
1818
run:
1919
working-directory: core-env/aws
@@ -33,23 +33,28 @@ jobs:
3333
uses: opentofu/setup-opentofu@v1
3434
- name: OpenTofu fmt
3535
id: fmt
36-
run: tofu fmt -check
36+
run: tofu fmt -check > /tmp/fmt.out
3737
continue-on-error: true
3838
- name: fmt output
3939
id: fmt_outcome
4040
run: echo "output=${{steps.fmt.outcome}}" >> "$GITHUB_OUTPUT"
4141
- run: tofu init
4242
- id: plan
43-
run: tofu plan -no-color
43+
run: tofu plan -no-color > /tmp/plan.out
4444
continue-on-error: true
4545
- name: plan output
46-
id: plan_output
47-
run: echo "output=${{steps.plan.outputs.stdout}}" >> "$GITHUB_OUTPUT"
46+
id: plan_outcome
47+
run: echo "output=${{steps.plan.outcome}}" >> "$GITHUB_OUTPUT"
48+
- name: Upload plan
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: output-aws
52+
path: /tmp/*.out
4853
eks_primary:
4954
needs: core_aws
5055
outputs:
51-
tofu-plan-aws: ${{ steps.plan_output.outputs.output }}
52-
tofu-fmt-aws: ${{ steps.fmt_outcome.outputs.output }}
56+
plan: ${{ steps.plan_output.outputs.output }}
57+
fmt: ${{ steps.fmt_outcome.outputs.output }}
5358
defaults:
5459
run:
5560
working-directory: core-env/eks-clusters
@@ -69,22 +74,33 @@ jobs:
6974
uses: opentofu/setup-opentofu@v1
7075
- name: OpenTofu fmt
7176
id: fmt
72-
run: tofu fmt -check
77+
run: tofu fmt -check > /tmp/fmt.out
7378
continue-on-error: true
7479
- name: fmt output
7580
id: fmt_outcome
7681
run: echo "output=${{steps.fmt.outcome}}" >> "$GITHUB_OUTPUT"
7782
- run: tofu init
7883
- id: plan
79-
run: tofu plan -no-color
84+
run: tofu plan -no-color > /tmp/plan.out
8085
continue-on-error: true
8186
- name: plan output
82-
id: plan_output
83-
run: echo "output=${{steps.plan.outputs.stdout}}" >> "$GITHUB_OUTPUT"
87+
id: plan_outcome
88+
run: echo "output=${{steps.plan.outcome}}" >> "$GITHUB_OUTPUT"
89+
- name: Upload plan
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: output-eks
93+
path: /tmp/*.out
8494
pr_comment:
8595
needs: eks_primary
8696
runs-on: ubuntu-latest
8797
steps:
98+
- name: Download artifact
99+
uses: actions/download-artifact@v4
100+
with:
101+
artifact-ids: [output-aws, output-eks]
102+
- name: Display structure of downloaded files
103+
run: ls -R .
88104
- uses: actions/github-script@v6
89105
with:
90106
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)