-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (31 loc) · 1.11 KB
/
deploy-prod.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
name: Deploy to AWS EC2
on:
pull_request:
branches:
- main
types:
- closed
jobs:
deploy:
if: github.event.pull_request.merged == true && github.event.pull_request.merge_commit_sha != null
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to EC2
env:
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/chit-chat-server.pem ubuntu@ec2-18-138-250-74.ap-southeast-1.compute.amazonaws.com << 'EOF'
cd ~/chit-chat-backend
git checkout main
git pull origin main
docker-compose -f ~/chit-chat-backend/docker/DockerCompose/docker-compose.prod.yml down
docker system prune -a --volumes -f
docker-compose -f ~/chit-chat-backend/docker/DockerCompose/docker-compose.prod.yml build
docker-compose -f ~/chit-chat-backend/docker/DockerCompose/docker-compose.prod.yml up -d
EOF