File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Docker CI/CD Pipeline
2
+
3
+ on :
4
+ push :
5
+ branches : [ "master" ]
6
+ pull_request :
7
+ branches : [ "master" ]
8
+
9
+ jobs :
10
+ build :
11
+ runs-on : ubuntu-latest
12
+
13
+ steps :
14
+ - name : Checkout repository
15
+ uses : actions/checkout@v2
16
+
17
+ - name : Set up Docker Buildx
18
+ uses : docker/setup-buildx-action@v2
19
+
20
+ - name : Log in to Docker Hub
21
+ uses : docker/login-action@v2
22
+ with :
23
+ username : ${{ secrets.DOCKER_USERNAME }}
24
+ password : ${{ secrets.DOCKER_PASSWORD }}
25
+
26
+ - name : Build and push Docker image
27
+ uses : docker/build-push-action@v4
28
+ with :
29
+ context : .
30
+ push : true
31
+ tags : ${{ secrets.DOCKER_USERNAME }}/bot-app:latest
32
+
33
+ deploy :
34
+ runs-on : ubuntu-latest
35
+ needs : build
36
+
37
+ steps :
38
+ - name : SSH to remote server and deploy
39
+ uses : appleboy/ssh-action@v0.1.5
40
+ with :
41
+ host : ${{ secrets.REMOTE_HOST }}
42
+ username : ${{ secrets.REMOTE_USER }}
43
+ key : ${{ secrets.REMOTE_SSH_KEY }}
44
+ script : |
45
+ docker pull ${{ secrets.DOCKER_USERNAME }}/my-app:latest
46
+ docker stop my-app || true
47
+ docker rm my-app || true
48
+ docker run -d --name bot-app -p ${{ secrets.PORT }}:${{ secrets.REMOTE_USER }} ${{ secrets.DOCKER_USERNAME }}/bot-app:latest --tg.token='${{ secrets.TG_BOT_TOKEN }}'
You can’t perform that action at this time.
0 commit comments