Skip to content

Commit

Permalink
Merge pull request #64 from LerianStudio/feature/set-email-notification
Browse files Browse the repository at this point in the history
feat:add new feature
  • Loading branch information
lfbarrile01 authored Dec 13, 2024
2 parents 1441e1b + 9b3240d commit c55021c
Show file tree
Hide file tree
Showing 15 changed files with 14,597 additions and 8,932 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mp4 filter=lfs diff=lfs merge=lfs -text
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: "Release"
name: Release and Build

on:
push:
pull_request:
branches:
- develop
- main
- hotfix/v*
types:
- closed

paths-ignore:
- '.gitignore'
- '**/*.env'
Expand All @@ -20,40 +22,14 @@ permissions:
contents: write
pull-requests: write

jobs:
integration_tests:
name: Run Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

- name: Install dependencies
run: npm ci

- name: Run Unit and Integration Tests
run: npm run test
env:
NODE_VERSION: '22'

publish_release:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')
runs-on: ubuntu-latest
needs: integration_tests
environment:
name: create_release
jobs:
release:
name: Create Release for Node.js Project
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@v1
Expand Down Expand Up @@ -83,17 +59,84 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
node-version: ${{ env.NODE_VERSION }}

- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Run Semantic Release
run: npx semantic-release
- name: Run Semantic Release and Capture Tag
id: semantic_release
run: |
TAG=$(npx semantic-release | grep 'The next release version is' | awk '{print $NF}')
echo "semantic_tag=$TAG" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GIT_AUTHOR_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}

build_and_publish:
name: Build and Publish Docker Image
needs: release
runs-on: ubuntu-latest
env:
APP_NAME: midaz-console
DOCKERHUB_ORG: lerianstudio
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"

- name: Generate Valid Docker Tag
id: valid_tag
run: echo "tag=${{ env.semantic_tag }}" >> $GITHUB_OUTPUT

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}
tags: |
${{ env.semantic_tag }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
load: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}:latest

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}:${{ env.semantic_tag }}'
format: 'table'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
exit-code: '1'

- name: Push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
69 changes: 0 additions & 69 deletions .github/workflows/build.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/commit-labelling
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Commit Labeling

on:
push:
branches:
- main
- develop
- hotfix/v*
- feature/*
paths-ignore:
- '.gitignore'
- '**/*.md'

jobs:
commit_labeling:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Check Commit Messages for "fix", "feat", "chore", or "release"
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)

if [[ "$COMMIT_MESSAGE" =~ ^fix ]]; then
echo "Commit is a FIX. Proceed with color labeling!"
echo "![Fix Badge](https://img.shields.io/badge/Fix-%23FF5733)"
elif [[ "$COMMIT_MESSAGE" =~ ^feat ]]; then
echo "Commit is a FEATURE. Proceed with color labeling!"
echo "![Feature Badge](https://img.shields.io/badge/Feature-%234CAF50)"
elif [[ "$COMMIT_MESSAGE" =~ ^chore ]]; then
echo "Commit is a CHORE. Proceed with color labeling!"
echo "![Chore Badge](https://img.shields.io/badge/Chore-%23FF9800)"
elif [[ "$COMMIT_MESSAGE" =~ ^release ]]; then
echo "Commit is a RELEASE. Proceed with color labeling!"
echo "![Release Badge](https://img.shields.io/badge/Release-%237E57C2)"
else
echo "Commit does not match 'fix', 'feat', 'chore', or 'release'. No action."
fi
54 changes: 46 additions & 8 deletions .github/workflows/notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Notification

on:
pull_request:
branches:
- develop
#branches:
#- develop
types:
- opened
- edited
Expand All @@ -19,36 +19,74 @@ 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 "::set-output name=tag::$RAW_RELEASE"
echo "tag=${RAW_RELEASE}" >> $GITHUB_ENV
# Notificar o Slack sobre nova release
- name: Notify Slack of New Release
uses: rtCamp/action-slack-notify@v2
if: '!github.event.prerelease'
if: always() # Sempre notificar (ou ajuste conforme necessário)
env:
SLACK_CHANNEL: "Marvin" # Channel of Slack
SLACK_CHANNEL: "Marvin" # Canal no Slack
SLACK_COLOR: "#36a64f"
SLACK_ICON_EMOJI: ":rocket"
SLACK_TITLE: "Midaz-Console New Release: ${{ steps.latest_release.outputs.tag }}"
SLACK_MESSAGE: "🎉 *Nova Release Publicada!* \n \n <https://github.com/${{ github.repository }}/releases/tag/${{ steps.latest_release.outputs.tag }} | *Clique aqui para detalhes*>"
SLACK_WEBHOOK: ${{ secrets.RELEASE_WEBHOOK_NOTIFICATION_URL }} # Webhook Release Notification
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>"
# }
# ]
# }'
24 changes: 0 additions & 24 deletions .release.rc

This file was deleted.

2 changes: 2 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CVE-2024-34156
CVE-2024-21538
Loading

0 comments on commit c55021c

Please sign in to comment.