Skip to content

Commit e5d9b77

Browse files
committed
k8s manifests
1 parent ba0e119 commit e5d9b77

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

.github/workflows/secured-CICD.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
build-trivy-scan-and-push:
3030
runs-on: ubuntu-latest
31-
#needs: sonarq-integration # Uncomment to ensure SonarQube analysis completes before the build
31+
needs: sonarq-integration # Uncomment to ensure SonarQube analysis completes before the build
3232

3333
steps:
3434
- name: Checkout code
@@ -113,3 +113,36 @@ jobs:
113113
with:
114114
name: zap-alerts
115115
path: ./report_html.html
116+
deploy-to-ec2:
117+
runs-on: ubuntu-latest
118+
needs: build-and-zap-scan
119+
steps:
120+
- name: Checkout code
121+
uses: actions/checkout@v2
122+
123+
- name: Configure SSH for EC2
124+
run: |
125+
echo "${{ secrets.EC2_PRIVATE_KEY }}" > ec2_key.pem
126+
chmod 600 ec2_key.pem
127+
echo "Connecting to EC2 Host: ${{ secrets.K8S_HOST }}"
128+
129+
- name: SSH into EC2 and deploy
130+
run: |
131+
scp -i ec2_key.pem configmap.yaml ubuntu@${{ secrets.K8S_HOST }}:/home/ubuntu/
132+
scp -i ec2_key.pem secret.yaml ubuntu@${{ secrets.K8S_HOST }}:/home/ubuntu/
133+
scp -i ec2_key.pem db-deployment.yaml ubuntu@${{ secrets.K8S_HOST }}:/home/ubuntu/
134+
scp -i ec2_key.pem web-deployment.yaml ubuntu@${{ secrets.K8S_HOST }}:/home/ubuntu/
135+
scp -i ec2_key.pem db-service.yaml ubuntu@${{ secrets.K8S_HOST }}:/home/ubuntu/
136+
scp -i ec2_key.pem web-service.yaml ubuntu@${{ secrets.K8S_HOST }}:/home/ubuntu/
137+
ssh -v -o StrictHostKeyChecking=no -i ec2_key.pem ubuntu@${{ secrets.K8S_HOST }} << EOF
138+
minikube stop
139+
minikube start
140+
kubectl create -f configmap.yaml
141+
kubectl create -f secret.yaml
142+
kubectl create -f db-deployment.yaml
143+
kubectl create -f web-deployment.yaml
144+
kubectl create -f db-service.yaml
145+
kubectl create -f web-service.yaml
146+
sleep 50
147+
kubectl get pods
148+
EOF

0 commit comments

Comments
 (0)