Skip to content

build: automatic update of frontend-production #344

build: automatic update of frontend-production

build: automatic update of frontend-production #344

Workflow file for this run

# ArgoCD Sync Workflow
# Uses ARGOCD_AUTH_TOKEN for headless authentication
# Requires: ARGOCD_TOKEN_STAGING and ARGOCD_TOKEN_PRODUCTION secrets
name: Sync ArgoCD
on:
push:
branches: [main]
paths:
- 'base/**'
- 'overlays/**'
- 'services/**'
- 'argocd/**'
workflow_dispatch:
inputs:
environment:
description: 'Environment to sync'
required: true
default: 'staging'
type: choice
options:
- staging
- production
- all
jobs:
sync-staging:
name: Sync Staging
runs-on: [self-hosted, staging, goapps-runner]
if: github.event_name == 'push' || github.event.inputs.environment == 'staging' || github.event.inputs.environment == 'all'
environment: staging
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get ArgoCD Pod
id: argocd
run: |
ARGOCD_POD=$(kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.name}')
echo "pod=$ARGOCD_POD" >> $GITHUB_OUTPUT
echo "Found ArgoCD pod: $ARGOCD_POD"
- name: Sync Applications
env:
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN_STAGING }}
run: |
echo "Syncing staging applications..."
ARGOCD_POD="${{ steps.argocd.outputs.pod }}"
# Use auth token via environment variable
kubectl exec -n argocd $ARGOCD_POD -- sh -c "
export ARGOCD_AUTH_TOKEN='$ARGOCD_AUTH_TOKEN'
argocd app sync infra-apps --server localhost:8080 --plaintext --prune || true
argocd app sync finance-service-staging --server localhost:8080 --plaintext --prune || true
argocd app sync frontend-staging --server localhost:8080 --plaintext --prune || true
argocd app sync iam-service-staging --server localhost:8080 --plaintext --prune || true
"
echo "Staging sync triggered"
- name: Wait for Healthy
env:
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN_STAGING }}
run: |
echo "Waiting for applications to be healthy..."
ARGOCD_POD="${{ steps.argocd.outputs.pod }}"
kubectl exec -n argocd $ARGOCD_POD -- sh -c "
export ARGOCD_AUTH_TOKEN='$ARGOCD_AUTH_TOKEN'
argocd app wait infra-apps --server localhost:8080 --plaintext --timeout 300 || true
argocd app wait finance-service-staging --server localhost:8080 --plaintext --timeout 600 || true
argocd app wait frontend-staging --server localhost:8080 --plaintext --timeout 600 || true
argocd app wait iam-service-staging --server localhost:8080 --plaintext --timeout 600 || true
"
echo "Applications healthy"
sync-production:
name: Sync Production
runs-on: [self-hosted, production, goapps-runner]
if: github.event.inputs.environment == 'all'
environment: production
needs: [sync-staging]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get ArgoCD Pod
id: argocd
run: |
ARGOCD_POD=$(kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.name}')
echo "pod=$ARGOCD_POD" >> $GITHUB_OUTPUT
- name: Sync Applications
env:
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN_PRODUCTION }}
run: |
echo "Syncing production applications..."
ARGOCD_POD="${{ steps.argocd.outputs.pod }}"
kubectl exec -n argocd $ARGOCD_POD -- sh -c "
export ARGOCD_AUTH_TOKEN='$ARGOCD_AUTH_TOKEN'
argocd app sync infra-apps --server localhost:8080 --plaintext --prune
argocd app sync finance-service-production --server localhost:8080 --plaintext --prune
argocd app sync iam-service-production --server localhost:8080 --plaintext --prune
argocd app sync frontend-production --server localhost:8080 --plaintext --prune
"
echo "Production sync triggered"
- name: Wait for Healthy
env:
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN_PRODUCTION }}
run: |
echo "Waiting for applications to be healthy..."
ARGOCD_POD="${{ steps.argocd.outputs.pod }}"
kubectl exec -n argocd $ARGOCD_POD -- sh -c "
export ARGOCD_AUTH_TOKEN='$ARGOCD_AUTH_TOKEN'
argocd app wait infra-apps --server localhost:8080 --plaintext --timeout 300
argocd app wait finance-service-production --server localhost:8080 --plaintext --timeout 600
argocd app wait iam-service-production --server localhost:8080 --plaintext --timeout 600
argocd app wait frontend-production --server localhost:8080 --plaintext --timeout 600
"
echo "Applications healthy"
sync-production-only:
name: Sync Production (Direct)
runs-on: [self-hosted, production, goapps-runner]
if: github.event.inputs.environment == 'production'
environment: production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get ArgoCD Pod
id: argocd
run: |
ARGOCD_POD=$(kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o jsonpath='{.items[0].metadata.name}')
echo "pod=$ARGOCD_POD" >> $GITHUB_OUTPUT
- name: Sync Applications
env:
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN_PRODUCTION }}
run: |
echo "Syncing production applications (direct)..."
ARGOCD_POD="${{ steps.argocd.outputs.pod }}"
kubectl exec -n argocd $ARGOCD_POD -- sh -c "
export ARGOCD_AUTH_TOKEN='$ARGOCD_AUTH_TOKEN'
argocd app sync infra-apps --server localhost:8080 --plaintext --prune
argocd app sync finance-service-production --server localhost:8080 --plaintext --prune
argocd app sync iam-service-production --server localhost:8080 --plaintext --prune
argocd app sync frontend-production --server localhost:8080 --plaintext --prune
"
echo "Production sync triggered"
- name: Wait for Healthy
env:
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN_PRODUCTION }}
run: |
echo "Waiting for applications to be healthy..."
ARGOCD_POD="${{ steps.argocd.outputs.pod }}"
kubectl exec -n argocd $ARGOCD_POD -- sh -c "
export ARGOCD_AUTH_TOKEN='$ARGOCD_AUTH_TOKEN'
argocd app wait infra-apps --server localhost:8080 --plaintext --timeout 300
argocd app wait finance-service-production --server localhost:8080 --plaintext --timeout 600
argocd app wait iam-service-production --server localhost:8080 --plaintext --timeout 600
argocd app wait frontend-production --server localhost:8080 --plaintext --timeout 600
"
echo "Applications healthy"