From 4508125414f335e0da1016a8d4500c691e900384 Mon Sep 17 00:00:00 2001 From: JoolsoftAdmin Date: Sat, 7 Dec 2024 08:26:27 +0700 Subject: [PATCH] test build discord --- .github/workflows/release.yaml | 54 ++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ae0fd03..ccd216e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,26 +1,19 @@ name: release run-name: release ${{ github.actor }} on: - # push: - # tags: - # - 'v[0-9]+.[0-9]+.[0-9]+' - # tags-ignore: - # - '2.*' - # Allow run workflow manually from Action tab + push: + tags: + - "version-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: - inputs: - IMAGE_VER: - description: "version for build image" - type: string env: REGISTRY: docker.frappet.com IMAGE_NAME: demo/qualifying-exam-cms - DEPLOY_HOST: 49.0.91.80 + DEPLOY_HOST: frappet.com COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-qualifying-cms + jobs: # act workflow_dispatch --reuse -W .github/workflows/release.yaml --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd # act --reuse --workflows .github/workflows/release.yaml --job release --input IMAGE_VER=v0.2.4-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd - release: runs-on: ubuntu-latest steps: @@ -77,3 +70,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success + - name: Notify Discord Success + if: success() + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "✅ Deployment Success!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", + "color": 3066993, + "footer": { + "text": "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": "❌ Deployment Failed!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", + "color": 15158332, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/failure-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }}