-
Notifications
You must be signed in to change notification settings - Fork 5
37 lines (33 loc) · 1.42 KB
/
website.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
name: Website Deployment
on:
push:
branches: ["main"]
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Cleanup disk space
run: |
# Remove all unused Docker data (images, containers, volumes, and networks)
sudo docker system prune -af
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Set Target Directory
run: |
echo "TARGET_DIR=/home/ec2-user/website/" >> $GITHUB_ENV
- name: Run deploy
run: |
set -x # Enable command tracing
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "${{ secrets.DEPLOYMENT_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -v 44.208.84.199 >> ~/.ssh/known_hosts
ssh -i ~/.ssh/id_rsa [email protected] "cd $TARGET_DIR/sparkai-chatbot-frontend/website && docker-compose down"
ssh -i ~/.ssh/id_rsa [email protected] "docker system prune -af"
rsync -avz --stats -e "ssh -v -i ~/.ssh/id_rsa" --exclude '.git' --exclude 'node_modules' . [email protected]:$TARGET_DIR/sparkai-chatbot-frontend
ssh -i ~/.ssh/id_rsa [email protected] "cd $TARGET_DIR/sparkai-chatbot-frontend/website && docker-compose build --no-cache && docker-compose up -d --force-recreate"