gcloud-lab/trading-platform/.github/workflows/build-push.yml
Sirius Devops d079d1239f feat: add trading platform K8s deployment infrastructure
- Add Helm chart with 19 templates (Deployments, Services, Ingress,
  ConfigMaps, Secrets, NetworkPolicy, cert-manager)
- Add Dockerfiles for 4 microservices (dashboard, data-service,
  execute-service, news-service)
- Add CI/CD workflows (build-test, build-push, deploy)
- Add raw K8s manifests, per-service Helm charts, and deploy scripts
- Add SOPS-encrypted secrets template and config
- Configure deployment to customer1 namespace
- Include infrastructure components: PostgreSQL, Redis, Kafka
2026-05-17 22:15:00 +00:00

109 lines
3.9 KiB
YAML

# Build and push container images to Artifact Registry
name: Build & Push Images
on:
push:
branches: [main, develop]
paths:
- "trading-platform/**"
- "!trading-platform/infra/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GCP_PROJECT_ID: customer1-gke
GCP_REGION: us-central1
ARTIFACT_REGISTRY: us-central1-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/trading
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/${{ env.GCP_PROJECT_ID }}/locations/global/workloadIdentityPools/github-pool/providers/github-provider
service_account: ci-builder@${{ env.GCP_PROJECT_ID }}.iam.gserviceaccount.com
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{ env.GCP_REGION }}-docker.pkg.dev --quiet
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Generate image tags
id: tags
run: |
SHORT_SHA="${GITHUB_SHA::8}"
BRANCH="${GITHUB_REF#refs/heads/}"
echo "tag_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "tag_branch=${BRANCH}" >> $GITHUB_OUTPUT
echo "tag_latest=${BRANCH}" >> $GITHUB_OUTPUT
# ---- Execute Service ----
- name: Build and push execute-service
uses: docker/build-push-action@v5
with:
context: trading-platform/execute-service
file: trading-platform/infra/dockerfiles/execute-service/Dockerfile
push: true
tags: |
${{ env.ARTIFACT_REGISTRY }}/execute-service:${{ steps.tags.outputs.tag_sha }}
${{ env.ARTIFACT_REGISTRY }}/execute-service:${{ steps.tags.outputs.tag_branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ---- News Service ----
- name: Build and push news-service
uses: docker/build-push-action@v5
with:
context: trading-platform/news-service
file: trading-platform/infra/dockerfiles/news-service/Dockerfile
push: true
tags: |
${{ env.ARTIFACT_REGISTRY }}/news-service:${{ steps.tags.outputs.tag_sha }}
${{ env.ARTIFACT_REGISTRY }}/news-service:${{ steps.tags.outputs.tag_branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ---- Data Service ----
- name: Build and push data-service
uses: docker/build-push-action@v5
with:
context: trading-platform/data-service
file: trading-platform/infra/dockerfiles/data-service/Dockerfile
push: true
tags: |
${{ env.ARTIFACT_REGISTRY }}/data-service:${{ steps.tags.outputs.tag_sha }}
${{ env.ARTIFACT_REGISTRY }}/data-service:${{ steps.tags.outputs.tag_branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ---- Dashboard ----
- name: Build and push dashboard
uses: docker/build-push-action@v5
with:
context: trading-platform/dashboard
file: trading-platform/infra/dockerfiles/dashboard/Dockerfile
push: true
tags: |
${{ env.ARTIFACT_REGISTRY }}/dashboard:${{ steps.tags.outputs.tag_sha }}
${{ env.ARTIFACT_REGISTRY }}/dashboard:${{ steps.tags.outputs.tag_branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Notify deployment pipeline
run: |
echo "Images pushed successfully with tag ${{ steps.tags.outputs.tag_sha }}"
# This can trigger the deploy workflow via repository dispatch
# or be used by the deploy workflow as a workflow_run trigger