generated from HenriqueAmorim20/GEROcuidadoAPITemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
47 lines (41 loc) · 1.26 KB
/
deploy.yml
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Deploy
on:
push:
branches: ['develop']
tags: ['v*.*.*']
env:
TARGET_DIR: '~/${{ github.event.repository.name }}'
jobs:
docker-hub:
name: Docker Hub Image Push
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Sending Image to Docker Hub
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: gerocuidadodev/gerocuidado-usuario-api
registry: docker.io
directory: ./
dockerfile: ./Dockerfile.prod
tags: latest
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
deploy-ec2:
name: Deploy EC2
needs: docker-hub
runs-on: ubuntu-latest
steps:
- name: Checkout the files
uses: actions/checkout@v2
- name: Executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST_DNS }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ${{env.TARGET_DIR}}
sudo git pull
sudo docker compose -f docker-compose.prod.yml up --force-recreate --build --pull --remove-orphans -d