Skip to content

Instantly share code, notes, and snippets.

@zviryatko
Last active October 21, 2025 06:56
Show Gist options
  • Save zviryatko/b6076d213910591ce51ed7ee26c8625a to your computer and use it in GitHub Desktop.
Save zviryatko/b6076d213910591ce51ed7ee26c8625a to your computer and use it in GitHub Desktop.
MS Teams notification webhook script
  1. Create MS Teams simple chat
  2. Add workflow to it (on the left chat list click to triple dots and select Workflows)
image
  1. Add next workflow - basically it should Receive Webhook and Post Adaptive Card
image
  1. Add next script to your project and run with ./deploy.sh "Site name" "Env name" (don't forget to replace webhook url with one from teams).

Here example of card:

image
#!/usr/bin/env bash
site="$1"
target_env="$2"
log_file="/tmp/deploy_log_$$.txt"
webhook_url="[PUT WEBHOOK URL HERE]"
{
echo "Started deployment for site: $site, environment: $target_env"
# Run your deployment command, for example "drush deploy"
} 2>&1 | tee "$log_file"
status=$?
if [ $status -eq 0 ]; then
status_msg="✅ Deployment succeeded for $site.$target_env."
color="Good"
else
status_msg="❌ Deployment failed for $site.$target_env."
color="Attention"
fi
# read log and let jq escape newlines properly
log_content=$(cat "$log_file")
json=$(jq -n \
--arg status_msg "$status_msg" \
--arg color "$color" \
--arg message "$log_content" \
'{
type: "message",
attachments: [
{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
type: "AdaptiveCard",
version: "1.5",
body: [
{ type: "TextBlock", text: $status_msg, color: $color, weight: "bolder", size: "large", wrap: true },
{ type: "TextBlock", text: $message, size: "small", wrap: true }
]
}
}
]
}' | sed 's/\\n/\\n\\n\\n\\n/g')
cat "$log_file"
curl -s -H "Content-Type: application/json" -d "${json}" "${webhook_url}" || true
rm -f "$log_file"
exit $status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment