Skip to content

Commit 6aac732

Browse files
committed
Enhance Teams notification with support for Power Automate webhook and improved payload creation
1 parent 086d5e1 commit 6aac732

1 file changed

Lines changed: 34 additions & 6 deletions

File tree

.github/workflows/build-deploy.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,17 +487,44 @@ jobs:
487487
echo "🔗 Webhook URL: ${WEBHOOK_PREVIEW}..."
488488
489489
# Validate webhook URL format
490-
if [[ "${{ secrets.TEAMS_WEBHOOK }}" == *"outlook.office.com/webhook"* ]] || [[ "${{ secrets.TEAMS_WEBHOOK }}" == *"office.com/webhookb2"* ]]; then
491-
echo "✅ Webhook URL format looks valid"
490+
if [[ "${{ secrets.TEAMS_WEBHOOK }}" == *"outlook.office.com/webhook"* ]]; then
491+
echo "✅ Direct Teams webhook detected"
492+
MESSAGE_TYPE="teams"
493+
elif [[ "${{ secrets.TEAMS_WEBHOOK }}" == *"powerplatform.com"* ]] && [[ "${{ secrets.TEAMS_WEBHOOK }}" == *"powerautomate"* ]]; then
494+
echo "✅ Power Automate workflow webhook detected"
495+
MESSAGE_TYPE="powerautomate"
492496
else
493497
echo "⚠️ Warning: Webhook URL format may be incorrect"
494-
echo "Expected: https://outlook.office.com/webhook/... or https://xxx.office.com/webhookb2/..."
498+
echo "Expected: Teams webhook or Power Automate workflow URL"
499+
MESSAGE_TYPE="unknown"
495500
fi
496501
497502
echo "🎨 Message color: $COLOR ($EMOJI)"
498503
499-
# Create Teams message payload
500-
cat > teams_payload.json << EOF
504+
# Create appropriate message payload based on webhook type
505+
if [ "$MESSAGE_TYPE" = "powerautomate" ]; then
506+
echo "📝 Creating Power Automate payload..."
507+
# Power Automate expects simpler JSON structure
508+
cat > teams_payload.json << EOF
509+
{
510+
"title": "ITL Identity Platform Deployment",
511+
"status": "$STATUS",
512+
"emoji": "$EMOJI",
513+
"color": "$COLOR",
514+
"version": "${{ github.ref_name }}",
515+
"commit": "$SHORT_SHA",
516+
"actor": "${{ github.actor }}",
517+
"trigger": "$TRIGGER",
518+
"workflow_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
519+
"repository": "${{ github.repository }}",
520+
"event": "${{ github.event_name }}",
521+
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
522+
}
523+
EOF
524+
else
525+
echo "📝 Creating Teams MessageCard payload..."
526+
# Direct Teams webhook expects MessageCard format
527+
cat > teams_payload.json << EOF
501528
{
502529
"@type": "MessageCard",
503530
"@context": "http://schema.org/extensions",
@@ -547,8 +574,9 @@ jobs:
547574
]
548575
}
549576
EOF
577+
fi
550578
551-
echo "📝 Teams message payload created"
579+
echo "📝 Message payload created for $MESSAGE_TYPE"
552580
echo "📄 Payload preview:"
553581
jq '.' teams_payload.json || cat teams_payload.json
554582

0 commit comments

Comments
 (0)