File tree 1 file changed +33
-0
lines changed 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : CI/CD Pipeline
2
+
3
+ on :
4
+ push :
5
+ branches : [ main ]
6
+
7
+ jobs :
8
+ build-and-deploy :
9
+ runs-on : ubuntu-latest
10
+
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v3
14
+
15
+ - name : Log in to Docker Hub
16
+ run : echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
17
+
18
+ - name : Build Docker image
19
+ run : docker build -t ${{ secrets.DOCKER_USERNAME }}/devops-webapp .
20
+
21
+ - name : Push Docker image
22
+ run : docker push ${{ secrets.DOCKER_USERNAME }}/devops-webapp
23
+
24
+ - name : SSH into Azure VM and deploy
25
+ uses : appleboy/ssh-action@master
26
+ with :
27
+ host : ${{ secrets.VM_HOST }}
28
+ username : ${{ secrets.VM_USER }}
29
+ key : ${{ secrets.VM_KEY }}
30
+ script : |
31
+ docker pull ${{ secrets.DOCKER_USERNAME }}/devops-webapp
32
+ docker stop webapp || true && docker rm webapp || true
33
+ docker run -d -p 80:5000 --name webapp ${{ secrets.DOCKER_USERNAME }}/devops-webapp
You can’t perform that action at this time.
0 commit comments