-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (55 loc) · 2.07 KB
/
deploy.yml
File metadata and controls
64 lines (55 loc) · 2.07 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Deploy to Homelab
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Cloudflare Client & Configure SSH
run: |
sudo mkdir -p /usr/local/bin
sudo curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared
sudo chmod +x /usr/local/bin/cloudflared
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo -e "Host act-bot.comonhq.com\n ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h\n StrictHostKeyChecking no" >> ~/.ssh/config
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# --- RUNNING AS ROOT ---
- name: Deploy to Homelab via Native SSH
run: |
ssh -i ~/.ssh/id_ed25519 root@act-bot.comonhq.com << 'EOF'
APP_DIR="/root/ACT"
REPO_URL="https://github.com/Comon-tech/ACT.git"
REMOTE="origin"
BRANCH="main"
if [ ! -d "$APP_DIR" ]; then
echo "Directory $APP_DIR does not exist. Creating and cloning..."
mkdir -p "$APP_DIR"
cd "$APP_DIR"
git clone --depth 1 "$REPO_URL" .
git checkout "$BRANCH"
else
cd "$APP_DIR"
if [ ! -d ".git" ]; then
echo "No git repo found, Re-cloning..."
rm -rf *
git clone --depth 1 "$REPO_URL" .
git checkout "$BRANCH"
else
echo "Fetching and resetting..."
git fetch "$REMOTE" "$BRANCH"
git reset --hard "$REMOTE"/"$BRANCH"
fi
fi
echo "Syncing dependencies with uv..."
/root/.local/bin/uv sync
echo "Restarting service..."
systemctl restart act-bot.service
sleep 3
systemctl status act-bot.service --no-pager
EOF