Skip to content

Commit a6ac202

Browse files
committed
Add Slack notification to Terraform Github workflow
1 parent ff9e7dd commit a6ac202

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/terraform-github.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,23 @@ jobs:
115115
- name: Terraform Apply
116116
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
117117
run: terraform apply -auto-approve -input=false
118+
119+
- name: Send message to Slack via Workflow Builder
120+
uses: slackapi/[email protected]
121+
with:
122+
payload: |
123+
{
124+
"channel-id": "${{ env.SLACK_CHANNEL_ID }}",
125+
"inputs": "${{ env.INPUTS }}",
126+
"message": "${{ env.MESSAGE }}",
127+
"results-url": "${{ env.RESULTS_URL }}",
128+
"workflow-url": "${{ env.WORKFLOW_URL }}"
129+
}
130+
env:
131+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
132+
SLACK_CHANNEL_ID: ${{ vars.SLACK_CHANNEL_ID }}
133+
INPUTS: "N/A"
134+
MESSAGE: "${{ github.workflow }}/${{ github.job }} GitHub Actions workflow failed :sob:"
135+
RESULTS_URL: "N/A"
136+
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
137+
if: failure() && github.ref == 'refs/heads/main' && github.event_name == 'push'

0 commit comments

Comments
 (0)