Skip to content

Commit 7807a1a

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/terraform-github.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,24 @@ 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+
# #release-train-alerts
133+
SLACK_CHANNEL_ID: C03B28HRP53
134+
INPUTS: "N/A"
135+
MESSAGE: "${{ github.workflow }}/${{ github.job }} GitHub Actions workflow failed :sob:"
136+
RESULTS_URL: "N/A"
137+
WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
138+
if: failure() && github.ref == 'refs/heads/main' && github.event_name == 'push'

0 commit comments

Comments
 (0)