Skip to content

Commit 55d9209

Browse files
authored
Merge pull request #80 from AET-DevOps25/workflow/enhance-cicd-and-helm-configurations
feat: enhance CI/CD workflows through terraform and pre-prod, prod namespaces deploy fix
2 parents 068372a + 9b40688 commit 55d9209

File tree

72 files changed

+3882
-4296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3882
-4296
lines changed

.github/workflows/client.yml

Lines changed: 93 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,93 @@
1-
name: check format for React App
2-
3-
on:
4-
push:
5-
paths:
6-
- "client/**"
7-
pull_request:
8-
paths:
9-
- "client/**"
10-
11-
jobs:
12-
client-check-format:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
18-
19-
- name: Set up Node.js
20-
uses: actions/setup-node@v4
21-
with:
22-
node-version: 22
23-
24-
- name: Install dependencies (Client)
25-
working-directory: ./client
26-
run: npm ci
27-
28-
- name: Run ESLint on changed files
29-
continue-on-error: true
30-
working-directory: ./client
31-
run: |
32-
changed_files=$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | grep -E '\.(js|jsx|ts|tsx)$' | sed 's|^client/||' || true)
33-
34-
if [ -n "$changed_files" ]; then
35-
echo "Running ESLint on changed files:"
36-
echo "$changed_files"
37-
npx eslint $changed_files
38-
else
39-
echo "No JavaScript/TypeScript files changed"
40-
fi
41-
42-
client-run-tests:
43-
runs-on: ubuntu-latest
44-
needs: client-check-format
45-
steps:
46-
- uses: actions/checkout@v4
47-
48-
- name: Set up Node.js
49-
uses: actions/setup-node@v4
50-
with:
51-
node-version: 22
52-
53-
- name: Install dependencies
54-
working-directory: ./client
55-
run: npm ci
56-
57-
- name: Run tests
58-
working-directory: ./client
59-
run: npm test
60-
61-
client-docker-build-push:
62-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
63-
runs-on: ubuntu-latest
64-
needs: [client-check-format, client-run-tests]
65-
permissions:
66-
packages: write
67-
contents: read
68-
steps:
69-
- uses: actions/checkout@v4
70-
71-
- name: Set up Docker Buildx
72-
uses: docker/setup-buildx-action@v3
73-
74-
- name: Log in to GitHub Container Registry
75-
uses: docker/login-action@v3
76-
with:
77-
registry: ghcr.io
78-
username: ${{ github.actor }}
79-
password: ${{ secrets.GITHUB_TOKEN }}
80-
81-
- name: Build and push Docker image
82-
uses: docker/build-push-action@v5
83-
with:
84-
context: ./client
85-
file: ./client/Dockerfile
86-
push: true
87-
tags: |
88-
ghcr.io/aet-devops25/team-cache-me-if-you-can/client:latest
89-
ghcr.io/aet-devops25/team-cache-me-if-you-can/client:${{ github.sha }}
90-
labels: |
91-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
92-
org.opencontainers.image.revision=${{ github.sha }}
93-
94-
client-deploy:
95-
name: Deploy to Kubernetes
96-
runs-on: ubuntu-latest
97-
needs: [client-check-format, client-run-tests, client-docker-build-push]
98-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
99-
100-
steps:
101-
- name: Checkout Code
102-
uses: actions/checkout@v4
103-
104-
- name: Set up Terraform
105-
uses: hashicorp/setup-terraform@v3
106-
107-
- name: Set up Kubernetes tools
108-
uses: azure/setup-kubectl@v3
109-
110-
- name: Configure kubeconfig
111-
run: |
112-
mkdir -p ~/.kube
113-
echo "${{ secrets.KUBE_CONFIG_DATA }}" > ~/.kube/config
114-
chmod 600 ~/.kube/config
115-
116-
- name: Terraform Init
117-
run: terraform init
118-
working-directory: ./client/terraform
119-
120-
- name: Terraform Plan
121-
run: terraform plan -var="redeploy_id=${{ github.sha }}"
122-
working-directory: ./client/terraform
123-
124-
- name: Terraform Apply
125-
run: terraform apply -auto-approve -var="redeploy_id=${{ github.sha }}"
126-
working-directory: ./client/terraform
127-
env:
128-
KUBECONFIG: $HOME/.kube/config
1+
name: Client Code Quality & Testing
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
paths:
7+
- "client/**"
8+
pull_request:
9+
branches: ['**']
10+
paths:
11+
- "client/**"
12+
13+
jobs:
14+
client-check-format:
15+
name: Code Quality Check
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
27+
- name: Install dependencies (Client)
28+
working-directory: ./client
29+
run: npm ci
30+
31+
- name: Run ESLint on changed files
32+
continue-on-error: true
33+
working-directory: ./client
34+
run: |
35+
changed_files=$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | grep -E '\.(js|jsx|ts|tsx)$' | sed 's|^client/||' || true)
36+
37+
if [ -n "$changed_files" ]; then
38+
echo "Running ESLint on changed files:"
39+
echo "$changed_files"
40+
npx eslint $changed_files
41+
else
42+
echo "No JavaScript/TypeScript files changed"
43+
fi
44+
45+
- name: Check TypeScript compilation
46+
working-directory: ./client
47+
run: npx tsc --noEmit
48+
49+
client-run-tests:
50+
name: Run Tests
51+
runs-on: ubuntu-latest
52+
needs: client-check-format
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Set up Node.js
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: 22
60+
61+
- name: Install dependencies
62+
working-directory: ./client
63+
run: npm ci
64+
65+
- name: Run tests
66+
working-directory: ./client
67+
run: npm test
68+
69+
- name: Run build test
70+
working-directory: ./client
71+
run: npm run build
72+
73+
deployment-notice:
74+
name: Deployment Information
75+
runs-on: ubuntu-latest
76+
needs: [client-check-format, client-run-tests]
77+
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
78+
steps:
79+
- name: Show deployment info
80+
run: |
81+
echo "ℹ️ **Client Deployment Information**"
82+
echo ""
83+
if [ "${{ github.event_name }}" = "pull_request" ]; then
84+
echo "🔄 **Pull Request detected**"
85+
echo "- Client will be deployed to **pre-prod** environment"
86+
echo "- Deployment handled by unified server-ci-cd.yml pipeline"
87+
echo "- URL: https://cache-me-if-you-can-client-pre-prod.team-cache-me-if-you-can.student.k8s.aet.cit.tum.de"
88+
elif [ "${{ github.ref }}" = "refs/heads/main" ]; then
89+
echo "🚀 **Main branch push detected**"
90+
echo "- Client will be deployed to **prod** environment"
91+
echo "- Deployment handled by unified server-ci-cd.yml pipeline"
92+
echo "- URL: https://cache-me-if-you-can-client-prod.team-cache-me-if-you-can.student.k8s.aet.cit.tum.de"
93+
fi

.github/workflows/docker-publish-genai.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
paths:
88
- 'genai/**'
9+
- 'helm/genai-chart/**'
10+
- 'infra/**'
11+
- '.github/workflows/genai-ci-cd.yml'
912

1013
jobs:
1114
build-and-push-image:

.github/workflows/genai-ci-cd.yml

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
name: Genai CI/CD Pipeline
1+
name: Genai CI/CD Pipeline - DISABLED (moved to unified pipeline)
2+
3+
# This workflow has been moved to server-ci-cd.yml (now unified-ci-cd.yml)
4+
# Keeping this file as backup for reference
25

36
on:
4-
push:
5-
branches:
6-
- '**' # Runs on push to any branch
7-
pull_request:
8-
branches:
9-
- main # Runs on pull requests targeting main (for tests before merge)
7+
# Disabled - remove automatic triggers
8+
workflow_dispatch: # Can only be triggered manually
109

1110
jobs:
1211
test:
1312
name: Run Pytest
1413
runs-on: ubuntu-latest
15-
if: github.event_name == 'push' || github.event_name == 'pull_request' # Ensure it runs for both pushes and PRs
14+
if: false # Disabled
1615

1716
steps:
1817
- name: Check out code
@@ -33,7 +32,7 @@ jobs:
3332
name: Deploy to Development
3433
runs-on: ubuntu-latest
3534
needs: test
36-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
35+
if: false # Disabled
3736

3837
steps:
3938
- name: Check out code
@@ -48,40 +47,29 @@ jobs:
4847
- name: Setup Helm
4948
uses: azure/setup-helm@v4
5049

50+
- name: Wait for server infrastructure
51+
run: |
52+
echo "Waiting for server infrastructure to be ready..."
53+
timeout=300
54+
while [ $timeout -gt 0 ]; do
55+
if kubectl get secret openai-credentials -n pre-prod >/dev/null 2>&1; then
56+
echo "✅ Infrastructure ready - OpenAI secret found"
57+
break
58+
fi
59+
echo "⏳ Waiting for infrastructure... ($timeout seconds remaining)"
60+
sleep 10
61+
timeout=$((timeout-10))
62+
done
63+
64+
if [ $timeout -le 0 ]; then
65+
echo "❌ Timeout waiting for infrastructure"
66+
exit 1
67+
fi
68+
5169
- name: Deploy to Kubernetes with Helm
5270
run: |
71+
# Deploy with Helm (infrastructure should have created openai-credentials secret)
5372
helm upgrade --install genai-dev ./helm/genai-chart \
54-
--namespace developmentv1 --create-namespace \
73+
--namespace devel --create-namespace \
5574
-f ./helm/genai-chart/values-development.yaml \
56-
--set image.tag=${{ github.sha }}
57-
58-
# deploy_preprod:
59-
# name: Deploy to Pre-production
60-
# runs-on: ubuntu-latest
61-
# needs: test
62-
# if: startsWith(github.ref, 'refs/tags/v') # Example: trigger on tags like v1.2.3
63-
#
64-
# steps:
65-
# ... (similar to deploy_dev)
66-
# - name: Deploy to Kubernetes with Helm
67-
# run: |
68-
# helm upgrade --install genai-preprod ./genai/helm/genai-chart \
69-
# --namespace preprod --create-namespace \
70-
# -f ./genai/helm/genai-chart/values-preprod.yaml \
71-
# --set image.tag=${{ github.ref_name }} # Use tag as image version
72-
#
73-
# deploy_prod:
74-
# name: Deploy to Production
75-
# runs-on: ubuntu-latest
76-
# needs: deploy_preprod # Chain deployments
77-
# environment: production # Use GitHub environments for protection rules
78-
# if: startsWith(github.ref, 'refs/tags/v')
79-
#
80-
# steps:
81-
# ... (similar to deploy_dev)
82-
# - name: Deploy to Kubernetes with Helm
83-
# run: |
84-
# helm upgrade --install genai-prod ./genai/helm/genai-chart \
85-
# --namespace prod --create-namespace \
86-
# -f ./genai/helm/genai-chart/values-prod.yaml \
87-
# --set image.tag=${{ github.ref_name }}
75+
--set image.tag=latest

0 commit comments

Comments
 (0)