From a4850df120b4ff34146df17205fdb4cec9fb7266 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 25 Feb 2025 11:46:31 +0700 Subject: [PATCH] feat: add discord noti to gitea action --- .github/workflows/gitea-local.yaml | 38 ++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitea-local.yaml b/.github/workflows/gitea-local.yaml index 754e16d..4770ee6 100644 --- a/.github/workflows/gitea-local.yaml +++ b/.github/workflows/gitea-local.yaml @@ -11,7 +11,7 @@ env: REGISTRY: ${{ vars.CONTAINER_REGISTRY }} REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} - + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }}/${{ vars.CONTAINER_IMAGE_NAME }}:latest jobs: gitea-release: runs-on: ubuntu-latest @@ -35,5 +35,39 @@ jobs: with: context: . platforms: linux/amd64 - tags: ${{ env.REGISTRY }}/chamomind/jws-backend:latest + tags: ${{ env.CONTAINER_IMAGE_NAME }} push: true + - name: Notify Discord Success + if: success() + run: | + curl -H "Content-Type: application/json" -X POST \ + -d '{ + "embeds": [{ + "title": "✅ Gitea Local Deployment Success!", + "description": "**Details:**\n- Image: `${{ env.CONTAINER_IMAGE_NAME }}`\n- Deployed by: `${{ github.actor }}`", + "color": 3066993, + "footer": { + "text": "Gitea Local Release Notification", + "icon_url": "https://example.com/success-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} + - name: Notify Discord Failure + if: failure() + run: | + curl -H "Content-Type: application/json" -X POST \ + -d '{ + "embeds": [{ + "title": "❌ Gitea Local Deployment Failed!", + "description": "**Details:**\n- Image: `${{ env.CONTAINER_IMAGE_NAME }}`\n- Attempted by: `${{ github.actor }}`", + "color": 15158332, + "footer": { + "text": "Gitea Local Release Notification", + "icon_url": "https://example.com/failure-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }}