mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-21 12:26:43 +02:00
🚀 ci: add dev branch workflow with PR validation
- Rename ci-main.yml to ci.yml for clarity - Add PR-based validation (type-check, lint) for dev and main branches - Add path filtering to skip CI on docs-only changes - Trigger staging deployment only on push to dev branch - Keep production deployment manual with confirmation
This commit is contained in:
parent
9ece591bb5
commit
8de629dd2d
3 changed files with 80 additions and 13 deletions
92
.github/workflows/ci-main.yml
vendored
92
.github/workflows/ci-main.yml
vendored
|
|
@ -1,92 +0,0 @@
|
|||
# MINIMAL: Only builds mana-core-auth + chat Docker images, no validation
|
||||
# Full config archived at: .github/workflows/ci-main.full.yml
|
||||
#
|
||||
# To restore: cp .github/workflows/ci-main.full.yml .github/workflows/ci-main.yml
|
||||
|
||||
name: CI - Main Branch
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Build Docker images directly - Dockerfiles handle their own dependencies
|
||||
build-docker-images:
|
||||
name: Build ${{ matrix.service.name }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
service:
|
||||
- { name: 'mana-core-auth', path: 'services/mana-core-auth', port: '3001' }
|
||||
- { name: 'chat-backend', path: 'apps/chat/apps/backend', port: '3002' }
|
||||
- { name: 'chat-web', path: 'apps/chat/apps/web', port: '3000' }
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Check if Dockerfile exists
|
||||
id: check-dockerfile
|
||||
run: |
|
||||
if [ -f "${{ matrix.service.path }}/Dockerfile" ]; then
|
||||
echo "exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "exists=false" >> $GITHUB_OUTPUT
|
||||
echo "::warning::No Dockerfile found for ${{ matrix.service.name }}"
|
||||
fi
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: steps.check-dockerfile.outputs.exists == 'true'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata
|
||||
if: steps.check-dockerfile.outputs.exists == 'true'
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.service.name }}
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Build and push
|
||||
if: steps.check-dockerfile.outputs.exists == 'true'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ${{ matrix.service.path }}/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
# Trigger staging deployment after all images are built
|
||||
deploy-staging:
|
||||
name: Deploy to Staging
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-docker-images
|
||||
steps:
|
||||
- name: Trigger staging deployment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
await github.rest.actions.createWorkflowDispatch({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
workflow_id: 'cd-staging.yml',
|
||||
ref: 'main'
|
||||
});
|
||||
console.log('Staging deployment triggered');
|
||||
Loading…
Add table
Add a link
Reference in a new issue