1- # name: Deploy to EC2
1+ name : Deploy to Homelab
22
3- # on:
4- # push:
5- # branches:
6- # - main
3+ on :
4+ push :
5+ branches :
6+ - main
77
8- # jobs:
9- # deploy:
10-
11- # runs-on: ubuntu-latest
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout repository
13+ uses : actions/checkout@v4
1214
13- # steps:
14- # - name: Checkout repository
15- # uses: actions/checkout@v4
15+ - name : Install Cloudflare Client & Configure SSH
16+ run : |
17+ sudo mkdir -p /usr/local/bin
18+ sudo curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared
19+ sudo chmod +x /usr/local/bin/cloudflared
20+
21+ mkdir -p ~/.ssh
22+ chmod 700 ~/.ssh
23+ echo -e "Host act-bot.comonhq.com\n ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h\n StrictHostKeyChecking no" >> ~/.ssh/config
24+
25+ echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
26+ chmod 600 ~/.ssh/id_ed25519
1627
17- # - name: Deploy to EC2
18- # uses: appleboy/ssh-action@v1.2.1
19- # with:
20- # host: ${{ secrets.EC2_HOST }}
21- # username: ${{ secrets.EC2_USER }}
22- # key: ${{ secrets.EC2_SSH_KEY }}
23- # command_timeout: "20m"
24- # script: |
25- # APP_DIR="/home/ubuntu/ACT"
26- # REPO_URL="https://github.com/Comon-tech/ACT.git"
27- # REMOTE="fork"
28- # BRANCH="main"
28+ # --- RUNNING AS ROOT ---
29+ - name : Deploy to Homelab via Native SSH
30+ run : |
31+ ssh -i ~/.ssh/id_ed25519 root@act-bot.comonhq.com << 'EOF'
32+ APP_DIR="/root/ACT"
33+ REPO_URL="https://github.com/Comon-tech/ACT.git"
34+ REMOTE="origin"
35+ BRANCH="main"
2936
30- # if [ ! -d "$APP_DIR" ]; then
31- # echo "Directory $APP_DIR does not exist. Creating and cloning..."
32- # mkdir -p "$APP_DIR"
33- # cd "$APP_DIR"
34- # git clone --depth 1 "$REPO_URL" .
35- # git checkout "$BRANCH"
36- # else
37- # cd "$APP_DIR"
38- # if [ ! -d ".git" ]; then
39- # echo "No git repo found, Re-cloning..."
40- # rm -rf *
41- # git clone --depth 1 "$REPO_URL" .
42- # git checkout "$BRANCH"
43- # else
44- # echo "Fetching and resetting..."
45- # git fetch "$REMOTE" "$BRANCH"
46- # git reset --hard "$REMOTE"/"$BRANCH"
47- # fi
48- # fi
37+ if [ ! -d "$APP_DIR" ]; then
38+ echo "Directory $APP_DIR does not exist. Creating and cloning..."
39+ mkdir -p "$APP_DIR"
40+ cd "$APP_DIR"
41+ git clone --depth 1 "$REPO_URL" .
42+ git checkout "$BRANCH"
43+ else
44+ cd "$APP_DIR"
45+ if [ ! -d ".git" ]; then
46+ echo "No git repo found, Re-cloning..."
47+ rm -rf *
48+ git clone --depth 1 "$REPO_URL" .
49+ git checkout "$BRANCH"
50+ else
51+ echo "Fetching and resetting..."
52+ git fetch "$REMOTE" "$BRANCH"
53+ git reset --hard "$REMOTE"/"$BRANCH"
54+ fi
55+ fi
4956
50- # echo "Restarting service..."
51- # sudo systemctl restart act-app.service
52- # sleep 3
53- # sudo systemctl status act-app.service --no-pager
57+ echo "Syncing dependencies with uv..."
58+ /root/.local/bin/uv sync
59+
60+ echo "Restarting service..."
61+ systemctl restart act-bot.service
62+ sleep 3
63+ systemctl status act-bot.service --no-pager
64+ EOF
0 commit comments