Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,23 @@ jobs:
run: terraform plan -no-color -input=false
continue-on-error: true

- name: Update Pull Request
uses: mshick/add-pr-comment@v2
if: github.event_name == 'pull_request'
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-regex: "^### Snapshot Service Plan"

# If the new deployment plan contains changes, post it in a comment.
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'pull_request' && !contains(steps.plan.outputs.stdout, 'No changes. Your infrastructure matches the configuration.')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
#### Terraform Plan 📖${{ steps.plan.outcome }}
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### Snapshot Service Plan: ${{ steps.plan.outcome }}

<details><summary>Show Plan</summary>

Expand All @@ -63,7 +72,15 @@ jobs:
```

</details>
edit-mode: replace

# If the new deployment plan contains no changes, delete the last posted plan.
- name: Delete comment
uses: detomarco/[email protected]
if: github.event_name == 'pull_request' && contains(steps.plan.outputs.stdout, 'No changes. Your infrastructure matches the configuration.')
with:
comment-id: ${{ steps.fc.outputs.comment-id }}

- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
Expand Down