Skip to content

Commit af89718

Browse files
committed
Alert slack on deploymnt failure
1 parent a0bd51d commit af89718

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/deploy-staging-network.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ jobs:
8181
major_version="${major_version%%.*}"
8282
echo "MAJOR_VERSION=$major_version" >> $GITHUB_ENV
8383
84+
- name: Force failure for testing
85+
run: exit 1
86+
8487
- name: Store the GCP key in a file
8588
if: env.MAJOR_VERSION == '2'
8689
env:
@@ -138,3 +141,21 @@ jobs:
138141
run: |
139142
echo "Updating monitoring app for testnet deployment..."
140143
./spartan/metrics/testnet-monitor/scripts/update-monitoring.sh testnet ${{ env.MONITORING_NAMESPACE }}
144+
145+
- name: Notify Slack on failure
146+
if: failure() && env.MAJOR_VERSION == '2'
147+
env:
148+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
149+
run: |
150+
if [ -n "${SLACK_BOT_TOKEN}" ]; then
151+
read -r -d '' data <<EOF
152+
{
153+
"channel": "#alerts-next-${{ inputs.network }}",
154+
"text": "Deploy Staging Network workflow FAILED for *${{ inputs.network }}* (version ${{ inputs.semver }}): <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>"
155+
}
156+
EOF
157+
curl -X POST https://slack.com/api/chat.postMessage \
158+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
159+
-H "Content-type: application/json" \
160+
--data "$data"
161+
fi

0 commit comments

Comments
 (0)