-
Notifications
You must be signed in to change notification settings - Fork 0
32 lines (30 loc) · 1 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
name: Build And Deploy
on:
pull_request:
branches:
- main
types:
- closed
jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'
cd ~/${{ secrets.REPOSITORY_NAME }}-prod
git checkout main
git stash push || true
git pull
git stash pop || true
sudo echo "${{ secrets.DOT_ENT_DJANGO }}" > .env-django
sudo echo "${{ secrets.DOT_ENT_MYSQL }}" > .env-mysql
sudo echo "${{ secrets.DOT_ENT_NEO4J }}" > .env-neo4j
sudo docker rm -f ${{ secrets.REPOSITORY_NAME }} || true
sudo docker-compose -f docker-compose.yml -f docker-compose-prod.yml up -d --build