-
Notifications
You must be signed in to change notification settings - Fork 5
99 lines (89 loc) · 4.25 KB
/
notification.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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>"
# }
# ]
# }'