Skip to content

Commit 0753dae

Browse files
committed
Enhance workflow inputs across multiple YAML files for ArgoCD, Deploy, Endpoints, Monitoring, and Terraform, ensuring required parameters are clearly defined and utilized in deployment steps.
1 parent dcb73d0 commit 0753dae

File tree

6 files changed

+177
-50
lines changed

6 files changed

+177
-50
lines changed

.github/workflows/argocd.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,31 @@ on:
33
workflow_dispatch:
44
workflow_call:
55
inputs:
6-
image-tag:
6+
cluster_name:
7+
description: 'EKS Cluster Name'
8+
required: true
9+
type: string
10+
app_namespace:
11+
description: 'Kubernetes Namespace for the Application'
12+
required: true
13+
type: string
14+
monitoring_namespace:
15+
description: 'Kubernetes Namespace for Monitoring'
16+
required: true
17+
type: string
18+
argocd_namespace:
19+
description: 'Kubernetes Namespace for ArgoCD'
20+
required: true
21+
type: string
22+
app_name:
23+
description: 'Name of the Application'
24+
required: true
25+
type: string
26+
image_tag:
727
description: 'Docker image tag to deploy'
828
required: false
929
default: ''
1030
type: string
11-
1231
jobs:
1332
argocd:
1433
name: ArgoCD & Monitoring Deployment
@@ -19,7 +38,7 @@ jobs:
1938

2039
- name: Wait for GitHub variables to propagate
2140
run: sleep 30
22-
41+
2342
- name: Checkout Repository
2443
uses: actions/checkout@v5
2544

@@ -31,7 +50,7 @@ jobs:
3150
aws-region: us-east-1
3251

3352
- name: Update kubeconfig
34-
run: aws eks update-kubeconfig --name ${{ vars.CLUSTER_NAME }} --region us-east-1
53+
run: aws eks update-kubeconfig --name ${{ inputs.cluster_name }} --region us-east-1
3554

3655
- name: Install Helm
3756
uses: azure/[email protected]
@@ -46,27 +65,27 @@ jobs:
4665
- name: Install/Upgrade ArgoCD
4766
run: |
4867
helm upgrade --install argocd argo/argo-cd \
49-
--namespace ${{ vars.ARGOCD_NAMESPACE }} \
68+
--namespace ${{ inputs.argocd_namespace }} \
5069
--create-namespace \
5170
--set server.service.type=LoadBalancer \
5271
--wait
5372
5473
- name: Create Application Namespace
5574
run: |
56-
kubectl create namespace ${{ vars.APP_NAMESPACE }} --dry-run=client -o yaml | kubectl apply -f -
57-
75+
kubectl create namespace ${{ inputs.app_namespace }} --dry-run=client -o yaml | kubectl apply -f -
76+
5877
- name: Deploy Helm Chart
5978
run: |
60-
helm upgrade --install ${{ vars.APP_NAME }} ./helm \
61-
--namespace ${{ vars.APP_NAMESPACE }} \
79+
helm upgrade --install ${{ inputs.app_name }} ./helm \
80+
--namespace ${{ inputs.app_namespace }} \
6281
--set mongo.uri="${{ secrets.MONGO_URI }}" \
6382
--set mongo.username="${{ secrets.MONGO_USERNAME }}" \
6483
--set mongo.password="${{ secrets.MONGO_PASSWORD }}" \
65-
--set image.tag="${{ inputs.image-tag || github.sha }}"
84+
--set image.tag="${{ inputs.image_tag || github.sha }}"
6685
6786
- name: Deploy ArgoCD Applications
6887
run: |
69-
export APP_NAME=${{ vars.APP_NAME }}
70-
export APP_NAMESPACE=${{ vars.APP_NAMESPACE }}
71-
export ARGOCD_NAMESPACE=${{ vars.ARGOCD_NAMESPACE }}
88+
export APP_NAME=${{ inputs.app_name }}
89+
export APP_NAMESPACE=${{ inputs.app_namespace }}
90+
export ARGOCD_NAMESPACE=${{ inputs.argocd_namespace }}
7291
envsubst < ./argocd/application.yml | kubectl apply -f -

.github/workflows/deploy.yml

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@ name: Kubernetes Deployment
22
on:
33
workflow_dispatch:
44
workflow_call:
5+
inputs:
6+
cluster_name:
7+
description: 'EKS Cluster Name'
8+
required: true
9+
type: string
10+
app_namespace:
11+
description: 'Kubernetes Namespace for the Application'
12+
required: true
13+
type: string
14+
monitoring_namespace:
15+
description: 'Kubernetes Namespace for Monitoring'
16+
required: true
17+
type: string
18+
argocd_namespace:
19+
description: 'Kubernetes Namespace for ArgoCD'
20+
required: true
21+
type: string
22+
app_name:
23+
description: 'Name of the Application'
24+
required: true
25+
type: string
26+
image_tag:
27+
description: 'Docker image tag to deploy'
28+
required: false
29+
default: ''
30+
type: string
531
jobs:
632
deploy:
733
name: Deploy to Kubernetes
@@ -21,25 +47,25 @@ jobs:
2147

2248
- name: Update kubeconfig
2349
run: |
24-
aws eks update-kubeconfig --name ${{ vars.CLUSTER_NAME }} --region us-east-1
25-
50+
aws eks update-kubeconfig --name ${{ inputs.cluster_name }} --region us-east-1
51+
2652
- name: Create Application Namespace
2753
run: |
28-
kubectl create namespace ${{ vars.APP_NAMESPACE }} --dry-run=client -o yaml | kubectl apply -f -
29-
54+
kubectl create namespace ${{ inputs.app_namespace }} --dry-run=client -o yaml | kubectl apply -f -
55+
3056
- name: Deploy Helm Chart
3157
run: |
32-
helm upgrade --install ${{ vars.APP_NAME }} ./helm \
33-
--namespace ${{ vars.APP_NAMESPACE }} \
58+
helm upgrade --install ${{ inputs.app_name }} ./helm \
59+
--namespace ${{ inputs.app_namespace }} \
3460
--set mongo.uri="${{ secrets.MONGO_URI }}" \
3561
--set mongo.username="${{ secrets.MONGO_USERNAME }}" \
3662
--set mongo.password="${{ secrets.MONGO_PASSWORD }}" \
37-
--set image.tag="${{ inputs.image-tag || github.sha }}"
38-
63+
--set image.tag="${{ inputs.image_tag || github.sha }}"
64+
3965
- name: Deploy ArgoCD Applications
4066
run: |
41-
export APP_NAME=${{ vars.APP_NAME }}
42-
export APP_NAMESPACE=${{ vars.APP_NAMESPACE }}
43-
export ARGOCD_NAMESPACE=${{ vars.ARGOCD_NAMESPACE }}
67+
export APP_NAME=${{ inputs.app_name }}
68+
export APP_NAMESPACE=${{ inputs.app_namespace }}
69+
export ARGOCD_NAMESPACE=${{ inputs.argocd_namespace }}
4470
envsubst < ./argocd/application.yml | kubectl apply -f -
4571

.github/workflows/endpoints.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@ name: Print Service Endpoints
22
on:
33
workflow_dispatch:
44
workflow_call:
5+
inputs:
6+
cluster_name:
7+
description: 'EKS Cluster Name'
8+
required: true
9+
type: string
10+
app_namespace:
11+
description: 'Kubernetes Namespace for the Application'
12+
required: true
13+
type: string
14+
monitoring_namespace:
15+
description: 'Kubernetes Namespace for Monitoring'
16+
required: true
17+
type: string
18+
argocd_namespace:
19+
description: 'Kubernetes Namespace for ArgoCD'
20+
required: true
21+
type: string
22+
app_name:
23+
description: 'Name of the Application'
24+
required: true
25+
type: string
26+
image_tag:
27+
description: 'Docker image tag to deploy'
28+
required: false
29+
default: ''
30+
type: string
531

632
jobs:
733
print-endpoints:
@@ -18,21 +44,21 @@ jobs:
1844

1945
- name: Update kubeconfig
2046
run: |
21-
aws eks update-kubeconfig --name ${{ vars.CLUSTER_NAME }} --region us-east-1
22-
47+
aws eks update-kubeconfig --name ${{ inputs.cluster_name }} --region us-east-1
48+
2349
- name: Print Service Endpoints
2450
run: |
2551
echo "================= SERVICE ENDPOINTS ================="
26-
ARGOCD_HOST=$(kubectl get svc argocd-server -n ${{ vars.ARGOCD_NAMESPACE }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
27-
PROM_HOST=$(kubectl get svc kube-prometheus-stack-prometheus -n ${{ vars.MONITORING_NAMESPACE }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
28-
GRAFANA_HOST=$(kubectl get svc kube-prometheus-stack-grafana -n ${{ vars.MONITORING_NAMESPACE }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
29-
APP_HOST=$(kubectl get svc ${{ vars.APP_NAME }}-svc -n ${{ vars.APP_NAMESPACE }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
52+
ARGOCD_HOST=$(kubectl get svc argocd-server -n ${{ inputs.argocd_namespace }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
53+
PROM_HOST=$(kubectl get svc kube-prometheus-stack-prometheus -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
54+
GRAFANA_HOST=$(kubectl get svc kube-prometheus-stack-grafana -n ${{ inputs.monitoring_namespace }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
55+
APP_HOST=$(kubectl get svc ${{ inputs.app_name }}-svc -n ${{ inputs.app_namespace }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' 2>/dev/null || echo 'Not found')
3056
echo "ArgoCD: http://$ARGOCD_HOST"
3157
echo "Prometheus: http://$PROM_HOST:9090"
3258
echo "Grafana: http://$GRAFANA_HOST"
3359
echo "App: http://$APP_HOST"
3460
echo "================= DEFAULT CREDENTIALS ================="
35-
ARGOCD_PASS=$(kubectl -n ${{ vars.ARGOCD_NAMESPACE }} get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' 2>/dev/null | base64 -d || echo 'Not found')
61+
ARGOCD_PASS=$(kubectl -n ${{ inputs.argocd_namespace }} get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' 2>/dev/null | base64 -d || echo 'Not found')
3662
echo "ArgoCD -> Username: admin"
3763
echo "ArgoCD -> Password: $ARGOCD_PASS"
3864
echo "Grafana -> Username: admin"

.github/workflows/main-pipeline.yml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ jobs:
130130
uses: ./.github/workflows/docker.yml
131131
secrets: inherit
132132

133-
# Terraform - runs after docker (for linear flow) when infra changes or manual dispatch
134133
terraform:
135134
name: Deploy Infrastructure
136135
needs: [docker, detect-changes]
@@ -167,53 +166,74 @@ jobs:
167166
)
168167
uses: ./.github/workflows/argocd.yml
169168
secrets: inherit
169+
with:
170+
cluster_name: ${{ needs.terraform.outputs.cluster_name }}
171+
app_namespace: ${{ needs.terraform.outputs.app_namespace }}
172+
monitoring_namespace: ${{ needs.terraform.outputs.monitoring_namespace }}
173+
argocd_namespace: ${{ needs.terraform.outputs.argocd_namespace }}
174+
app_name: ${{ needs.terraform.outputs.app_name }}
175+
image_tag: ${{ github.sha }}
170176
permissions:
171177
contents: write
172178
packages: write
173179
id-token: write
174180
actions: read
175181

176-
# Application Deployment - runs after ArgoCD when infra changes or manual dispatch
177-
deployment:
178-
name: Deploy Application
182+
# Monitoring - runs first after ArgoCD
183+
monitoring:
184+
name: Deploy Monitoring Stack
179185
needs: [argocd, detect-changes]
180186
if: |
181187
!cancelled() &&
182-
!inputs.skip-deployment &&
188+
!inputs.skip-monitoring &&
183189
(needs.argocd.result == 'success' || (needs.argocd.result == 'skipped' && inputs.skip-argocd)) && (
184190
inputs.force-all ||
185191
(github.event_name == 'workflow_dispatch') ||
186192
needs.detect-changes.outputs.infra-changed == 'true'
187193
)
188-
uses: ./.github/workflows/deploy.yml
194+
uses: ./.github/workflows/monitoring.yml
189195
secrets: inherit
196+
with:
197+
cluster_name: ${{ needs.terraform.outputs.cluster_name }}
198+
app_namespace: ${{ needs.terraform.outputs.app_namespace }}
199+
monitoring_namespace: ${{ needs.terraform.outputs.monitoring_namespace }}
200+
argocd_namespace: ${{ needs.terraform.outputs.argocd_namespace }}
201+
app_name: ${{ needs.terraform.outputs.app_name }}
202+
image_tag: ${{ github.sha }}
190203
permissions:
191204
contents: write
192205
packages: write
193206
id-token: write
194207
actions: read
195208

196-
# Monitoring - runs in parallel with deployment after ArgoCD
197-
monitoring:
198-
name: Deploy Monitoring Stack
199-
needs: [argocd, detect-changes]
209+
# Application Deployment - runs after monitoring completes
210+
deployment:
211+
name: Deploy Application
212+
needs: [monitoring, detect-changes]
200213
if: |
201214
!cancelled() &&
202-
!inputs.skip-monitoring &&
203-
(needs.argocd.result == 'success' || (needs.argocd.result == 'skipped' && inputs.skip-argocd)) && (
215+
!inputs.skip-deployment &&
216+
(needs.monitoring.result == 'success' || (needs.monitoring.result == 'skipped' && inputs.skip-monitoring)) && (
204217
inputs.force-all ||
205218
(github.event_name == 'workflow_dispatch') ||
206219
needs.detect-changes.outputs.infra-changed == 'true'
207220
)
208-
uses: ./.github/workflows/monitoring.yml
221+
uses: ./.github/workflows/deploy.yml
209222
secrets: inherit
223+
with:
224+
cluster_name: ${{ needs.terraform.outputs.cluster_name }}
225+
app_namespace: ${{ needs.terraform.outputs.app_namespace }}
226+
monitoring_namespace: ${{ needs.terraform.outputs.monitoring_namespace }}
227+
argocd_namespace: ${{ needs.terraform.outputs.argocd_namespace }}
228+
app_name: ${{ needs.terraform.outputs.app_name }}
229+
image_tag: ${{ github.sha }}
210230
permissions:
211231
contents: write
212232
packages: write
213233
id-token: write
214234
actions: read
215235

216-
# Show endpoints - runs after both deployment and monitoring complete
236+
# Show endpoints - runs after deployment completes
217237
show-endpoints:
218238
name: Show Service Endpoints
219239
needs: [detect-changes, deployment, monitoring]
@@ -227,6 +247,13 @@ jobs:
227247
)
228248
uses: ./.github/workflows/endpoints.yml
229249
secrets: inherit
250+
with:
251+
cluster_name: ${{ needs.terraform.outputs.cluster_name }}
252+
app_namespace: ${{ needs.terraform.outputs.app_namespace }}
253+
monitoring_namespace: ${{ needs.terraform.outputs.monitoring_namespace }}
254+
argocd_namespace: ${{ needs.terraform.outputs.argocd_namespace }}
255+
app_name: ${{ needs.terraform.outputs.app_name }}
256+
image_tag: ${{ github.sha }}
230257
permissions:
231258
contents: read
232259
id-token: write

.github/workflows/monitoring.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@ name: Monitoring Deployment
22
on:
33
workflow_dispatch:
44
workflow_call:
5+
inputs:
6+
cluster_name:
7+
description: 'EKS Cluster Name'
8+
required: true
9+
type: string
10+
app_namespace:
11+
description: 'Kubernetes Namespace for the Application'
12+
required: true
13+
type: string
14+
monitoring_namespace:
15+
description: 'Kubernetes Namespace for Monitoring'
16+
required: true
17+
type: string
18+
argocd_namespace:
19+
description: 'Kubernetes Namespace for ArgoCD'
20+
required: true
21+
type: string
22+
app_name:
23+
description: 'Name of the Application'
24+
required: true
25+
type: string
26+
image_tag:
27+
description: 'Docker image tag to deploy'
28+
required: false
29+
default: ''
30+
type: string
531

632
jobs:
733
monitoring:
@@ -21,19 +47,19 @@ jobs:
2147
aws-region: us-east-1
2248

2349
- name: Update kubeconfig
24-
run: aws eks update-kubeconfig --name ${{ vars.CLUSTER_NAME }} --region us-east-1
50+
run: aws eks update-kubeconfig --name ${{ inputs.cluster_name }} --region us-east-1
2551

2652
- name: Create Grafana Secret
2753
run: |
28-
kubectl create namespace ${{ vars.MONITORING_NAMESPACE }} --dry-run=client -o yaml | kubectl apply -f -
54+
kubectl create namespace ${{ inputs.monitoring_namespace }} --dry-run=client -o yaml | kubectl apply -f -
2955
kubectl create secret generic grafana-admin-secret \
3056
--from-literal=admin-user=admin \
3157
--from-literal=admin-password='${{ secrets.GRAFANA_ADMIN_PASSWORD }}' \
32-
--namespace ${{ vars.MONITORING_NAMESPACE }} \
58+
--namespace ${{ inputs.monitoring_namespace }} \
3359
--dry-run=client -o yaml | kubectl apply -f -
3460
3561
- name: Deploy Monitoring
3662
run: |
37-
export MONITORING_NAMESPACE=${{ vars.MONITORING_NAMESPACE }}
38-
export ARGOCD_NAMESPACE=${{ vars.ARGOCD_NAMESPACE }}
63+
export MONITORING_NAMESPACE=${{ inputs.monitoring_namespace }}
64+
export ARGOCD_NAMESPACE=${{ inputs.argocd_namespace }}
3965
envsubst < ./argocd/monitoring.yml | kubectl apply -f -

0 commit comments

Comments
 (0)