-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.yml
More file actions
31 lines (27 loc) · 956 Bytes
/
main.yml
File metadata and controls
31 lines (27 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
name: CI-CD Using Jenkins
on:
push:
branches:
- main
jobs:
my-first-job:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Build Docker Image
run: |
docker build . -t myimage .
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker tag myimage akdochub/myimage
docker push akdochub/myimage
- name: Setup SSH Key
run: |
echo "${{ secrets.EC2_PRIVATE_KEY }}" > /tmp/ssh_key
chmod 600 /tmp/ssh_key
- name: Connect to EC2
run: |
ssh -o "StrictHostKeyChecking=no" -i /tmp/ssh_key ubuntu@3.0.102.45 "
kubectl delete deployment my-deployment
kubectl apply -f /home/ubuntu/my-deployment.yml
"