Skip to content

Commit 31ab6a0

Browse files
committed
deploying
1 parent f914954 commit 31ab6a0

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/secured-CICD.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,29 @@ jobs:
105105
target: http://${{ env.container_ip }}:8000
106106
artifact_name: "zap-alerts"
107107
- name: Verify ZAP Alerts File Generation
108-
run: ls -l
108+
run: ls -l | grep report
109109
- name: Upload ZAP Alerts as Artifact
110110
uses: actions/upload-artifact@v4
111111
with:
112112
name: zap-alerts
113-
path: ./report_html.html
113+
path: ./report_html.html
114+
deploy-to-ec2:
115+
runs-on: ubuntu-latest
116+
needs: build-trivy-scan-and-push
117+
steps:
118+
- name: Checkout code
119+
uses: actions/checkout@v2
120+
- name: Convert Docker Compose to Kubernetes manifests
121+
run: kompose convert --out k8s-manifests
122+
- name: Configure SSH for EC2
123+
run: |
124+
echo "${{ secrets.EC2_PRIVATE_KEY }}" > ec2_key.pem
125+
chmod 600 ec2_key.pem
126+
ssh -o StrictHostKeyChecking=no -i ec2_key.pem ubuntu@${{ secrets.EC2_HOST }} 'echo Connection Successful'
127+
- name: Deploy Kubernetes manifests to EC2
128+
run: |
129+
scp -o StrictHostKeyChecking=no -i ec2_key.pem k8s-manifests/* ubuntu@${{ secrets.EC2_HOST }}:/home/ubuntu/
130+
ssh -o StrictHostKeyChecking=no -i ec2_key.pem ubuntu@${{ secrets.EC2_HOST }} << EOF
131+
kubectl apply -f /home/ubuntu/
132+
kubectl get pods
133+
EOF

0 commit comments

Comments
 (0)