From 41393d80aaca6420abd345ceb1d6c7acc7d26b27 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 18 Jun 2024 13:04:24 -0500 Subject: [PATCH] feat: notificacion dc --- .github/workflows/motify-discord-aproved.yml | 20 ++++++++++++ .../motify-discord-needsqaurgent.yml | 19 ++++++++++++ .github/workflows/notify-discord-needsqa.yml | 19 ++++++++++++ .github/workflows/notify-discord-on-merge.yml | 31 +++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 .github/workflows/motify-discord-aproved.yml create mode 100644 .github/workflows/motify-discord-needsqaurgent.yml create mode 100644 .github/workflows/notify-discord-needsqa.yml create mode 100644 .github/workflows/notify-discord-on-merge.yml diff --git a/.github/workflows/motify-discord-aproved.yml b/.github/workflows/motify-discord-aproved.yml new file mode 100644 index 00000000..cc4b129f --- /dev/null +++ b/.github/workflows/motify-discord-aproved.yml @@ -0,0 +1,20 @@ +name: Notify Discord on Pull Request + +on: + pull_request: + types: [opened, labeled] + +jobs: + notify-discord: + if: ${{ contains(github.event.pull_request.labels.*.name, 'qa-ready') }} + runs-on: ubuntu-latest + + steps: + - name: Send notification to Discord + env: + DISCORD_QA_APPROVED: ${{ secrets.DISCORD_QA_APPROVED }} + run: | + MENTION="<@1156585123978940486>" + PR_URL="${{ github.event.pull_request.html_url }}" + PAYLOAD="{\"content\": \"Pull request aprobado: ${PR_URL}\nMencionado: ${MENTION}\"}" + curl -H \"Content-Type: application/json\" -d \"$PAYLOAD\" $DISCORD_QA_APPROVED diff --git a/.github/workflows/motify-discord-needsqaurgent.yml b/.github/workflows/motify-discord-needsqaurgent.yml new file mode 100644 index 00000000..fe8ecbc6 --- /dev/null +++ b/.github/workflows/motify-discord-needsqaurgent.yml @@ -0,0 +1,19 @@ +name: Notify Discord on Pull Request + +on: + pull_request: + types: [opened, labeled] + +jobs: + notify-discord: + if: ${{ contains(github.event.pull_request.labels.*.name, 'needs-qa-urgent') }} + runs-on: ubuntu-latest + + steps: + - name: Send notification to Discord + env: + DISCORD_QA_FRONT: ${{ secrets.DISCORD_QA_FRONT }} + run: | + MENTION="<@481837609199599636>" + PAYLOAD=$(jq -n --arg url "${{ github.event.pull_request.html_url }}" --arg mention "$MENTION" '{"content": "🚨 **Nuevo pull request que necesita QA URGENTE** 🚨:\n\($url)\n📢 Mencionado: \($mention)"}') + curl -H "Content-Type: application/json" -d "$PAYLOAD" $DISCORD_QA_FRONT diff --git a/.github/workflows/notify-discord-needsqa.yml b/.github/workflows/notify-discord-needsqa.yml new file mode 100644 index 00000000..1de5abcb --- /dev/null +++ b/.github/workflows/notify-discord-needsqa.yml @@ -0,0 +1,19 @@ +name: Notify Discord on Pull Request + +on: + pull_request: + types: [opened] + +jobs: + notify-discord: + if: ${{ contains(github.event.pull_request.labels.*.name, 'needs-qa') }} + runs-on: ubuntu-latest + + steps: + - name: Send notification to Discord + env: + DISCORD_QA_FRONT: ${{ secrets.DISCORD_QA_FRONT }} + run: | + MENTION="<@481837609199599636>" + PAYLOAD=$(jq -n --arg url "${{ github.event.pull_request.html_url }}" --arg mention "$MENTION" '{"content": "Nuevo pull request que necesita QA: \($url)\nMencionado: \($mention)"}') + curl -H "Content-Type: application/json" -d "$PAYLOAD" $DISCORD_QA_FRONT diff --git a/.github/workflows/notify-discord-on-merge.yml b/.github/workflows/notify-discord-on-merge.yml new file mode 100644 index 00000000..f7d013de --- /dev/null +++ b/.github/workflows/notify-discord-on-merge.yml @@ -0,0 +1,31 @@ +name: Notify Discord on Merge to Production + +on: + pull_request: + types: [closed] + branches: + - production + +jobs: + notify-discord: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Send notification to Discord + env: + DISCORD_MERGE: ${{ secrets.DISCORD_MERGE }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_SHA: ${{ github.sha }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + COMMIT_URL="https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}" + MENTION="<@690191607307567119>" + curl -H "Content-Type: application/json" \ + -d "{\"content\": \"Se ha hecho merge a la rama production en el repositorio ${GITHUB_REPOSITORY}:\nPull Request: ${PR_URL}\nTítulo: ${PR_TITLE}\nCommit: [${GITHUB_SHA}](${COMMIT_URL})\nAutor: ${{ github.actor }}\nMencionado: ${MENTION}\"}" \ + $DISCORD_MERGE