-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (41 loc) · 1.35 KB
/
deploy.yaml
File metadata and controls
44 lines (41 loc) · 1.35 KB
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
name: Deploy to VPS
on:
push:
branches:
- main
workflow_dispatch: # Enable manual trigger in web UI.
env:
VPS_HOST: "5.161.78.151"
VPS_USER: "github"
PROJECT_PATH: "/srv/chainference"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy
run: |
temp_key=$(mktemp)
echo "${{ secrets.SSH_KEY }}" > "$temp_key"
chmod 600 "$temp_key"
ssh -i "$temp_key" -o StrictHostKeyChecking=no ${VPS_USER}@${VPS_HOST} << EOF
set -euxo pipefail
# Check if the project folder is a valid git repo
if [ ! -d "${PROJECT_PATH}/.git" ]; then
echo "Project directory is missing or not a git repository. Performing initial setup..."
rm -rf "${PROJECT_PATH}"
mkdir -p "${PROJECT_PATH}"
chown -R ${VPS_USER}:${VPS_USER} "${PROJECT_PATH}"
git clone --depth=1 git@github.com:marcospgp/chainference.git "${PROJECT_PATH}"
cd "${PROJECT_PATH}"
else
echo "Project directory exists and is a git repository. Updating..."
cd "${PROJECT_PATH}"
git fetch --depth=1
git reset --hard origin/main
fi
cd frontend
docker compose down
docker compose up -d --build
EOF
rm "$temp_key"