-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (39 loc) · 1.14 KB
/
cd.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
name: CD
on:
push:
branches:
- deploy
paths-ignore:
- "README.md"
- ".github/workflows/**"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Save Private Key
run: |
echo "${{ secrets.EC2_PRIVATE_KEY }}" > /tmp/id_rsa.pem
chmod 600 /tmp/id_rsa.pem
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ubuntu
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
sudo chown -R ubuntu:ubuntu /home/ubuntu/mydjangoapp
git config --global --add safe.directory /home/ubuntu/mydjangoapp
cd /home/ubuntu/mydjangoapp
git stash -u
git pull origin deploy
docker-compose down
docker-compose build --no-cache
docker-compose up -d
docker-compose restart web
echo "Deployment completed successfully."