Skip to content
Open
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
96 changes: 96 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# CI/CD Pipeline for FinMind Deployment
# Builds Docker images and pushes to GHCR on main branch
name: Build & Deploy

on:
push:
branches: [main]
paths:
- 'packages/backend/**'
- 'app/**'
- 'docker-compose.yml'
- 'deploy/**'
pull_request:
branches: [main]
paths:
- 'packages/backend/**'
- 'app/**'
- 'deploy/**'

env:
REGISTRY: ghcr.io
BACKEND_IMAGE: ghcr.io/${{ github.repository_owner }}/finmind-backend
FRONTEND_IMAGE: ghcr.io/${{ github.repository_owner }}/finmind-frontend

jobs:
# ── Validate deployment configs ──
validate:
name: Validate Configs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Validate JSON files
run: |
for f in deploy/platforms/aws/ecs-fargate/task-definition.json deploy/platforms/vercel/vercel.json deploy/platforms/heroku/app.json; do
echo "Validating $f..."
python3 -m json.tool "$f" > /dev/null
done

- name: Validate YAML files
run: |
pip install pyyaml
for f in deploy/platforms/render/render.yaml deploy/platforms/gcp/cloudrun.yaml deploy/platforms/digitalocean/app-platform/do-app-spec.yaml deploy/helm/finmind/values.yaml; do
echo "Validating $f..."
python3 -c "import yaml; yaml.safe_load(open('$f'))"
done

- name: Lint Helm chart
run: |
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm lint deploy/helm/finmind

# ── Build Docker images ──
build:
name: Build Images
runs-on: ubuntu-latest
needs: validate
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- name: backend
context: packages/backend
dockerfile: packages/backend/Dockerfile
image_env: BACKEND_IMAGE
- name: frontend
context: app
dockerfile: app/Dockerfile
image_env: FRONTEND_IMAGE
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ${{ matrix.name }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name == 'push' }}
tags: |
${{ env[matrix.image_env] }}:latest
${{ env[matrix.image_env] }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
Loading