From c07a20afa038639a929ed18df23a15f42b81c6dd Mon Sep 17 00:00:00 2001 From: raghu Date: Mon, 15 Dec 2025 19:29:58 -0500 Subject: [PATCH] add discord notifications --- .gitea/workflows/deploy.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 4117cc5..76fd579 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -34,19 +34,27 @@ jobs: - name: Clean up old images run: docker image prune -f - # Email notification using curl (Gmail SMTP) - - name: Send success email + - name: Set Discord mention + id: discord + run: | + echo "mention=<@${{ secrets.DISCORD_ID_RAGHU }}>" >> $GITEA_OUTPUT + + # āœ… Success notification + - name: Discord Success Notification if: success() run: | - cat > /tmp/email.txt << 'ENDMAIL' - From: GitHub Actions - To: raghu6004@gmail.com - Subject: Deployment Successful - Portfolio + curl -X POST -H "Content-Type: application/json" \ + -d "{ + \"content\": \"āœ… **Deployment SUCCESS**\nšŸ‘¤ ${{ steps.discord.outputs.mention }}\nšŸ“¦ Repo: ${{ gitea.repository }}\n🌿 Branch: ${{ gitea.ref_name }}\" + }" \ + ${{ secrets.DISCORD_WEBHOOK_URL }} - Deployment completed successfully! - Repository: ${{ github.repository }} - Branch: ${{ github.ref_name }} - Commit: ${{ github.sha }} - ENDMAIL - curl --ssl-reqd --url smtps://smtp.gmail.com:465 --user "${{ secrets.EMAIL_USERNAME }}:${{ secrets.EMAIL_PASSWORD }}" --mail-from "${{ secrets.EMAIL_USERNAME }}" --mail-rcpt raghu6004@gmail.com --upload-file /tmp/email.txt - rm /tmp/email.txt + # āŒ Failure notification + - name: Discord Failure Notification + if: failure() + run: | + curl -X POST -H "Content-Type: application/json" \ + -d "{ + \"content\": \"āŒ **Deployment FAILED**\nšŸ‘¤ ${{ steps.discord.outputs.mention }}\nšŸ“¦ Repo: ${{ gitea.repository }}\n🌿 Branch: ${{ gitea.ref_name }}\nšŸ” Check Gitea Actions logs\" + }" \ + ${{ secrets.DISCORD_WEBHOOK_URL }}