Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,24 @@ jobs:
name: relatorio-cobertura-${{ github.run_number }}
path: coverage/
retention-days: 7

# ─── Validação do Dockerfile (sem push) ───────────────────────────────────
docker-build:
name: Validar Dockerfile
runs-on: ubuntu-latest
needs: cobertura
timeout-minutes: 10
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- name: Build da imagem de produção (sem push)
uses: docker/build-push-action@v6
with:
context: .
target: prod
push: false
83 changes: 48 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,43 +240,11 @@ jobs:
- name: Auditoria de dependências
run: pnpm audit --audit-level=high

# ─── Artifact de produção ─────────────────────────────────────────────────
artifact-build:
name: Artifact de Produção
runs-on: ubuntu-latest
needs: security-scan
timeout-minutes: 10
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Instalar dependências (somente produção)
run: pnpm install --frozen-lockfile --prod

- name: Compilar projeto
run: pnpm build

- name: Upload do artifact de produção
uses: actions/upload-artifact@v4
with:
name: dist-${{ github.ref_name }}
path: dist/
retention-days: 30

# ─── Aprovação manual antes de produção ───────────────────────────────────
# ─── Aprovação manual — gate antes de qualquer push para produção ─────────
aprovacao-producao:
name: Aprovacao para Producao
runs-on: ubuntu-latest
needs: artifact-build
needs: security-scan
timeout-minutes: 10
environment: producao
permissions:
Expand All @@ -288,4 +256,49 @@ jobs:
echo "Tag: ${{ github.ref_name }}"
echo "Commit: ${{ github.sha }}"
echo "Aprovado por: ${{ github.actor }}"
echo "Release liberado para producao."

# ─── Build e push da imagem Docker para o Docker Hub ──────────────────────
docker-push:
name: Build e Push Docker Hub
runs-on: ubuntu-latest
needs: aprovacao-producao
timeout-minutes: 15
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- name: Login no Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Gerar metadados da imagem
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/bemvindo
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest

- name: Build e push da imagem de produção
uses: docker/build-push-action@v6
with:
context: .
target: prod
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Resumo do deploy
run: |
echo "Imagem publicada: ${{ secrets.DOCKER_USERNAME }}/bemvindo:${{ github.ref_name }}"
echo "Tags: ${{ steps.meta.outputs.tags }}"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "tsx watch --env-file=.env src/infra/http/servidor.ts",
"build": "tsc",
"build": "tsc && tsc-alias",
"start": "node dist/infra/http/servidor.js",
"prepare": "husky",
"lint": "eslint src",
Expand All @@ -30,6 +30,7 @@
"husky": "^9.1.7",
"lint-staged": "^17.0.5",
"pino-pretty": "^13.1.3",
"tsc-alias": "^1.8.17",
"tsx": "^4.22.3",
"typescript": "6.0.3",
"typescript-eslint": "^8.60.0",
Expand Down
Loading
Loading