Skip to content

Commit c24e543

Browse files
committed
fix: embed HTML marker in comment body and delete/recreate for fresh timestamp
1 parent 898dfa7 commit c24e543

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

.github/workflows/opentofu.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,35 @@ jobs:
6262
tail -n 1000 plan-filtered.txt > plan-filtered-truncated.txt
6363
mv plan-filtered-truncated.txt plan-filtered.txt
6464
65-
- name: Find existing comment
65+
- name: prepare-comment
66+
run: |
67+
{
68+
echo '<!-- opentofu-plan -->'
69+
echo '#### OpenTofu Plan'
70+
echo '```'
71+
cat plan-filtered.txt
72+
echo '```'
73+
} > comment-body.md
74+
75+
- name: find-comment
6676
uses: peter-evans/find-comment@v3
6777
id: fc
6878
with:
6979
issue-number: ${{ github.event.pull_request.number }}
7080
comment-author: 'github-actions[bot]'
7181
body-includes: '<!-- opentofu-plan -->'
7282

73-
- name: Comment PR with Plan
83+
- name: delete-comment
84+
if: steps.fc.outputs.comment-id != ''
85+
run: gh api repos/${{ github.repository }}/issues/comments/${{ steps.fc.outputs.comment-id }} -X DELETE
86+
env:
87+
GH_TOKEN: ${{ github.token }}
88+
89+
- name: comment
7490
uses: peter-evans/create-or-update-comment@v4
7591
with:
76-
comment-id: ${{ steps.fc.outputs.comment-id }}
7792
issue-number: ${{ github.event.pull_request.number }}
78-
body-path: plan-filtered.txt
79-
body-prefix: |
80-
<!-- opentofu-plan -->
81-
#### OpenTofu Plan
82-
```
83-
body-suffix: |
84-
```
85-
edit-mode: replace
93+
body-path: comment-body.md
8694

8795
apply:
8896
name: OpenTofu Apply

0 commit comments

Comments
 (0)