File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed
Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ name: Deploy on EC2-Instance
33on :
44 workflow_run :
55 workflows : ["Docker Image CI"]
6- branches : ["deploy"]
76 types : [completed]
87
98jobs :
1918 host : ${{secrets.HOST_DNS}}
2019 username : ${{secrets.EC2_USER}}
2120 key : ${{secrets.EC2_SSH_KEY}}
22-
21+ -
Original file line number Diff line number Diff line change 55 branches : ["deploy"]
66
77jobs :
8-
8+ env :
9+ DOCKER_USERNAME : ${{secrets.DOCKER_USERNAME}}
10+ DOCKER_PASSWORD : ${{secrets.DOCKER_PASSWORD}}
11+
912 build :
10-
1113 runs-on : ubuntu-latest
1214
1315 steps :
1416 - uses : actions/checkout@v3
1517
16- - name : Login Dockerhub
17- env :
18- DOCKER_USERNAME : ${{secrets.DOCKER_USERNAME}}
19- DOCKER_PASSWORD : ${{secrets.DOCKER_PASSWORD}}
18+ - name : Login Dockerhub
2019 run : docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
2120
2221 - name : Build Docker Container
2322 uses : docker/build-push-action@v6
2423 with :
2524 context : ./Frontend
2625 tags : thomastejedor/quiz-slayer-env:latest
26+ push : true
2727 secrets : |
2828 "PRIVATE_KEY=${{secrets.PRIVATE_SSL_KEY}}"
2929 "SSL_CERT=${{secrets.SSL_CERT}}"
30-
30+ deploy :
31+ name : Deploy to EC2
32+ runs-on : ubuntu-latest
33+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
34+ steps :
35+
36+ - name : Deploy via SSH
37+ uses : appleboy/ssh-action@v0.1.10
38+ with :
39+ host : ${{secrets.HOST_DNS}}
40+ username : ${{secrets.EC2_USER}}
41+ key : ${{secrets.EC2_SSH_KEY}}
42+
43+ - name : Pull Docker image
44+ run : sudo docker pull thomastejedor/quiz-slayer-env:latest
45+ - name : Delete old docker container
46+ run : sudo docker rm -f cicd-pipeline-container || true
47+ - name : Run Docker Container
48+ run : sudo docker run -itd -p 80:80 -p 443:443 cicd-pipeline-container thomastejedor/quiz-slayer-env
3149
You can’t perform that action at this time.
0 commit comments