From 4125c9db1875ebd3d8cad7b8b4fa87fac15d8ea2 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 17 Nov 2025 14:42:00 +0100 Subject: [PATCH] feat: add Discord notifications for CI/CD pipeline status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added two notification jobs that send Discord webhooks: - notify-success: Sends a green embed when pipeline succeeds - notify-failure: Sends a red embed when pipeline fails Notifications include: - Repository and branch information - Commit SHA with clickable link - Docker image names (backend & frontend) - Link to workflow run for debugging Requires DISCORD_WEBHOOK_URL secret to be configured in repository settings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/ci.yml | 114 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a70fe8..819c239 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -227,17 +227,123 @@ jobs: echo "## 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "### Backend Image" >> $GITHUB_STEP_SUMMARY - echo "- Registry: \`${{ env.REGISTRY }}/backend\`" >> $GITHUB_STEP_SUMMARY + echo "- Registry: \`${{ env.REGISTRY }}/xpeditis-backend\`" >> $GITHUB_STEP_SUMMARY echo "- Branch: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "### Frontend Image" >> $GITHUB_STEP_SUMMARY - echo "- Registry: \`${{ env.REGISTRY }}/frontend\`" >> $GITHUB_STEP_SUMMARY + echo "- Registry: \`${{ env.REGISTRY }}/xpeditis-frontend\`" >> $GITHUB_STEP_SUMMARY echo "- Branch: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "### Pull Commands" >> $GITHUB_STEP_SUMMARY echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY - echo "docker pull ${{ env.REGISTRY }}/backend:${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY - echo "docker pull ${{ env.REGISTRY }}/frontend:${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.REGISTRY }}/xpeditis-backend:${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.REGISTRY }}/xpeditis-frontend:${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + + # ============================================ + # Discord Notification - Success + # ============================================ + notify-success: + name: Discord Notification (Success) + runs-on: ubuntu-latest + needs: [backend, frontend] + if: success() + + steps: + - name: Send Discord notification + run: | + curl -H "Content-Type: application/json" \ + -d '{ + "embeds": [{ + "title": "✅ CI/CD Pipeline Success", + "description": "Deployment completed successfully!", + "color": 3066993, + "fields": [ + { + "name": "Repository", + "value": "${{ github.repository }}", + "inline": true + }, + { + "name": "Branch", + "value": "${{ github.ref_name }}", + "inline": true + }, + { + "name": "Commit", + "value": "[${{ github.sha }}](${{ github.event.head_commit.url }})", + "inline": false + }, + { + "name": "Backend Image", + "value": "`${{ env.REGISTRY }}/xpeditis-backend:${{ github.ref_name }}`", + "inline": false + }, + { + "name": "Frontend Image", + "value": "`${{ env.REGISTRY }}/xpeditis-frontend:${{ github.ref_name }}`", + "inline": false + }, + { + "name": "Workflow", + "value": "[${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", + "inline": false + } + ], + "timestamp": "${{ github.event.head_commit.timestamp }}", + "footer": { + "text": "Xpeditis CI/CD" + } + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK_URL }} + + # ============================================ + # Discord Notification - Failure + # ============================================ + notify-failure: + name: Discord Notification (Failure) + runs-on: ubuntu-latest + needs: [backend, frontend] + if: failure() + + steps: + - name: Send Discord notification + run: | + curl -H "Content-Type: application/json" \ + -d '{ + "embeds": [{ + "title": "❌ CI/CD Pipeline Failed", + "description": "Deployment failed! Check the logs for details.", + "color": 15158332, + "fields": [ + { + "name": "Repository", + "value": "${{ github.repository }}", + "inline": true + }, + { + "name": "Branch", + "value": "${{ github.ref_name }}", + "inline": true + }, + { + "name": "Commit", + "value": "[${{ github.sha }}](${{ github.event.head_commit.url }})", + "inline": false + }, + { + "name": "Workflow", + "value": "[${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", + "inline": false + } + ], + "timestamp": "${{ github.event.head_commit.timestamp }}", + "footer": { + "text": "Xpeditis CI/CD" + } + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK_URL }}