Merge pull request #166 from LerianStudio/feature/transactions-global… #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Notification | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
jobs: | |
github-releases-notification: | |
runs-on: ubuntu-latest | |
steps: | |
# Obter token do GitHub App | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }} | |
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }} | |
# Fazer checkout do código | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
# Instalar CLI do GitHub | |
- name: Install GitHub CLI | |
run: sudo apt-get install -y gh | |
# Obter última release do repositório | |
- name: Fetch Latest Release | |
id: latest_release | |
env: | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
run: | | |
RAW_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 1 --json tagName --jq '.[0].tagName') | |
echo "Raw release: $RAW_RELEASE" | |
echo "tag=${RAW_RELEASE}" >> $GITHUB_ENV | |
# Definir a mensagem com base na branch | |
- name: Set Message for Slack Notification | |
id: set_message | |
run: | | |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then | |
echo "message=🎉 *Nova Release na branch main* \n \n <https://github.com/${{ github.repository }}/releases/tag/${{ env.tag }} | *Clique aqui para detalhes*>" >> $GITHUB_ENV | |
elif [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then | |
echo "message=🚀 *Nova Release na branch develop* \n \n <https://github.com/${{ github.repository }}/releases/tag/${{ env.tag }} | *Clique aqui para detalhes*>" >> $GITHUB_ENV | |
fi | |
# Notificar o Slack sobre nova release | |
- name: Notify Slack of New Release | |
uses: rtCamp/action-slack-notify@v2 | |
if: always() # Sempre notificar (ou ajuste conforme necessário) | |
env: | |
SLACK_CHANNEL: "Marvin" # Canal no Slack | |
SLACK_COLOR: "#36a64f" | |
SLACK_ICON_EMOJI: ":rocket" | |
SLACK_TITLE: "Midaz-Console New Release: ${{ env.tag }}" | |
SLACK_MESSAGE: "🎉 *Nova Release Publicada!* \n \n <https://github.com/${{ github.repository }}/releases/tag/${{ env.tag }} | *Clique aqui para detalhes*>" | |
SLACK_WEBHOOK: ${{ secrets.RELEASE_WEBHOOK_NOTIFICATION_URL }} | |
# # Enviar e-mail usando SendGrid | |
# - name: Send Email using SendGrid | |
# env: | |
# SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} | |
# TAG: ${{ env.tag }} | |
# REPOSITORY: ${{ github.repository }} | |
# run: | | |
# curl -X POST https://api.sendgrid.com/v3/mail/send \ | |
# -H "Authorization: Bearer $SENDGRID_API_KEY" \ | |
# -H "Content-Type: application/json" \ | |
# -d '{ | |
# "personalizations": [ | |
# { | |
# "to": [ | |
# { | |
# "email": "releases@lerian.studio" | |
# } | |
# ], | |
# "subject": "🎉 Nova Release Disponível: v${TAG}" | |
# } | |
# ], | |
# "from": { | |
# "email": "noreply@lerian.studio", | |
# "name": "Lerian Studio Notifications" | |
# }, | |
# "content": [ | |
# { | |
# "type": "text/html", | |
# "value": "<!DOCTYPE html>\n<html>\n<head>\n <style>\n body {\n font-family: Arial, sans-serif;\n line-height: 1.6;\n }\n h1 {\n color: #36a64f;\n text-align: center;\n }\n p {\n margin: 15px 0;\n }\n a {\n color: #007bff;\n text-decoration: none;\n font-weight: bold;\n }\n </style>\n</head>\n<body>\n <h1>🚀 Nova Release Publicada!</h1>\n <p>Estamos felizes em anunciar que uma nova release foi publicada para o projeto.</p>\n <p>Confira os detalhes e as melhorias diretamente no nosso repositório:</p>\n <p><a href=\"https://github.com/${REPOSITORY}/releases/tag/${TAG}\">Clique aqui para acessar a release v${TAG}</a></p>\n <p>Obrigado por acompanhar nosso trabalho! 💡</p>\n <p>Atenciosamente,</p>\n <p><strong>Lerian Studio Team</strong></p>\n</body>\n</html>" | |
# } | |
# ] | |
# }' |