From 0aa2fe45c8a5305b2303f699b47ee44e07731001 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:05:03 -0300 Subject: [PATCH 01/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index de54841..41321e2 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -1,5 +1,5 @@ name: PR to Google Chat - +# Teste on: pull_request: types: [opened, reopened, synchronize] From 33a1ba3efd004b787da41b52ba526394a3f62f3a Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:09:41 -0300 Subject: [PATCH 02/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index 41321e2..882f0b7 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -1,15 +1,18 @@ name: PR to Google Chat -# Teste + on: pull_request: types: [opened, reopened, synchronize] jobs: - notify: + notify-gchat: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - name: List files (debug) + run: ls -l + + - name: List all files (debug) + run: ls -lR - name: Send PR details to Google Chat env: From 39e4ce0da90a5bd07ab8e741b388b7b7704e6489 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:11:34 -0300 Subject: [PATCH 03/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index 882f0b7..f106beb 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -22,4 +22,4 @@ jobs: PR_AUTHOR: ${{ github.event.pull_request.user.login }} run: | pip install requests - python send_to_gchat.py + python .github/workflows/send_to_gchat.py From 6daacae8dd9d0ce1a459f0d0ed77179509f8e9f0 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:13:24 -0300 Subject: [PATCH 04/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index f106beb..78c416b 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -20,6 +20,6 @@ jobs: PR_TITLE: ${{ github.event.pull_request.title }} PR_URL: ${{ github.event.pull_request.html_url }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} - run: | - pip install requests - python .github/workflows/send_to_gchat.py + run: | + pip install requests + python $GITHUB_WORKSPACE/.github/workflows/send_to_gchat.py From 7f63906b43d40e5bec8f09aae14f7713321b4797 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:15:22 -0300 Subject: [PATCH 05/11] Update send_to_gchat.py --- .github/workflows/send_to_gchat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/send_to_gchat.py b/.github/workflows/send_to_gchat.py index 140a293..f6fc3c4 100644 --- a/.github/workflows/send_to_gchat.py +++ b/.github/workflows/send_to_gchat.py @@ -1,6 +1,6 @@ import os import requests - +#teste GCHAT_WEBHOOK_URL = os.environ['GCHAT_WEBHOOK_URL'] PR_TITLE = os.environ['PR_TITLE'] PR_URL = os.environ['PR_URL'] From 29bce7f3c2003b8b05732c0539b5060a39aab6f9 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:17:36 -0300 Subject: [PATCH 06/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index 78c416b..c258ac4 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -20,6 +20,6 @@ jobs: PR_TITLE: ${{ github.event.pull_request.title }} PR_URL: ${{ github.event.pull_request.html_url }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} - run: | + run: | pip install requests python $GITHUB_WORKSPACE/.github/workflows/send_to_gchat.py From 5f2fdf48062af34e3bd90b2a8eab81ddade6b96d Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:20:31 -0300 Subject: [PATCH 07/11] Create send_to_gchat.py --- .github/workflows/scripts/send_to_gchat.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/scripts/send_to_gchat.py diff --git a/.github/workflows/scripts/send_to_gchat.py b/.github/workflows/scripts/send_to_gchat.py new file mode 100644 index 0000000..f6fc3c4 --- /dev/null +++ b/.github/workflows/scripts/send_to_gchat.py @@ -0,0 +1,14 @@ +import os +import requests +#teste +GCHAT_WEBHOOK_URL = os.environ['GCHAT_WEBHOOK_URL'] +PR_TITLE = os.environ['PR_TITLE'] +PR_URL = os.environ['PR_URL'] +PR_AUTHOR = os.environ['PR_AUTHOR'] + +message = { + "text": f"@all\nNovo Pull Request aberto por *{PR_AUTHOR}*:\n*{PR_TITLE}*\nVeja mais: {PR_URL}" +} + +response = requests.post(GCHAT_WEBHOOK_URL, json=message) +response.raise_for_status() From 0de7495bd0e640b1f2ad222dbf7283979a39d6e5 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:20:54 -0300 Subject: [PATCH 08/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index c258ac4..3f3ef5f 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -21,5 +21,5 @@ jobs: PR_URL: ${{ github.event.pull_request.html_url }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} run: | - pip install requests - python $GITHUB_WORKSPACE/.github/workflows/send_to_gchat.py + pip install requests + python .github/scripts/send_to_gchat.py From add99c3fbc381bc2ddb8db2a3f3b70b64c3d23c5 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:24:39 -0300 Subject: [PATCH 09/11] Update send_to_gchat.py --- .github/workflows/scripts/send_to_gchat.py | 33 ++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/scripts/send_to_gchat.py b/.github/workflows/scripts/send_to_gchat.py index f6fc3c4..ba3cee2 100644 --- a/.github/workflows/scripts/send_to_gchat.py +++ b/.github/workflows/scripts/send_to_gchat.py @@ -1,14 +1,31 @@ import os import requests -#teste -GCHAT_WEBHOOK_URL = os.environ['GCHAT_WEBHOOK_URL'] -PR_TITLE = os.environ['PR_TITLE'] -PR_URL = os.environ['PR_URL'] -PR_AUTHOR = os.environ['PR_AUTHOR'] +# Lê variáveis de ambiente +webhook_url = os.environ['GCHAT_WEBHOOK_URL'] +title = os.environ.get('PR_TITLE', '(sem título)') +body = os.environ.get('PR_BODY', '(sem descrição)') +author = os.environ.get('PR_AUTHOR', 'desconhecido') +url = os.environ.get('PR_URL', '') +status = os.environ.get('PR_STATUS', 'desconhecido') + +# Formata a mensagem message = { - "text": f"@all\nNovo Pull Request aberto por *{PR_AUTHOR}*:\n*{PR_TITLE}*\nVeja mais: {PR_URL}" + "text": ( + f"*Novo evento de Pull Request*: `{status}`\n\n" + f"📌 *Título:* {title}\n" + f"📝 *Descrição:* {body}\n" + f"👤 *Autor:* {author}\n" + f"🔗 *Link:* {url}" + ) } -response = requests.post(GCHAT_WEBHOOK_URL, json=message) -response.raise_for_status() +# Envia a mensagem +response = requests.post(webhook_url, json=message) + +# Verifica sucesso +if response.status_code != 200: + print(f"Erro ao enviar para Google Chat: {response.status_code} - {response.text}") + response.raise_for_status() +else: + print("Mensagem enviada com sucesso para o Google Chat.") From ba135db52d53ed2471a559278dd4e4afae1f23c2 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:24:53 -0300 Subject: [PATCH 10/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index 3f3ef5f..2714e78 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -8,18 +8,22 @@ jobs: notify-gchat: runs-on: ubuntu-latest steps: - - name: List files (debug) - run: ls -l + - name: Checkout code + uses: actions/checkout@v3 - - name: List all files (debug) - run: ls -lR + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' - - name: Send PR details to Google Chat + - name: Enviar PR para Google Chat env: GCHAT_WEBHOOK_URL: ${{ secrets.GCHAT_WEBHOOK_URL }} PR_TITLE: ${{ github.event.pull_request.title }} + PR_BODY: ${{ github.event.pull_request.body }} PR_URL: ${{ github.event.pull_request.html_url }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_STATUS: ${{ github.event.action }} run: | pip install requests python .github/scripts/send_to_gchat.py From 28181f381c5ccc410f8c4097b2c1ed48c03fbc45 Mon Sep 17 00:00:00 2001 From: Atirson Fabiano Date: Fri, 13 Jun 2025 09:25:58 -0300 Subject: [PATCH 11/11] Update pr-to-gchat.yml --- .github/workflows/pr-to-gchat.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr-to-gchat.yml b/.github/workflows/pr-to-gchat.yml index 2714e78..713e8a4 100644 --- a/.github/workflows/pr-to-gchat.yml +++ b/.github/workflows/pr-to-gchat.yml @@ -8,14 +8,6 @@ jobs: notify-gchat: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Enviar PR para Google Chat env: GCHAT_WEBHOOK_URL: ${{ secrets.GCHAT_WEBHOOK_URL }} @@ -25,5 +17,10 @@ jobs: PR_AUTHOR: ${{ github.event.pull_request.user.login }} PR_STATUS: ${{ github.event.action }} run: | - pip install requests - python .github/scripts/send_to_gchat.py + MESSAGE="{ + \"text\": \"*Novo evento de Pull Request*: \`${PR_STATUS}\`\n\n📌 *Título:* ${PR_TITLE}\n📝 *Descrição:* ${PR_BODY}\n👤 *Autor:* ${PR_AUTHOR}\n🔗 *Link:* ${PR_URL}\" + }" + + curl -X POST -H 'Content-Type: application/json' \ + -d "${MESSAGE}" \ + "$GCHAT_WEBHOOK_URL"