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+ # --- ADD THIS STEP TO BRIDGE THE CLOUDFLARE TUNNEL ---
16+ - name : Install Cloudflare Client & Configure SSH Proxy
17+ run : |
18+ sudo mkdir -p /usr/local/bin
19+ sudo curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared
20+ sudo chmod +x /usr/local/bin/cloudflared
21+ mkdir -p ~/.ssh
22+ echo -e "Host *\n ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h" >> ~/.ssh/config
1623
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"
24+ - name : Deploy to Homelab
25+ uses : appleboy/ssh-action@v1.2.1
26+ with :
27+ host : ${{ secrets.HOST }}
28+ username : ${{ secrets.USER }}
29+ key : ${{ secrets.SSH_KEY }}
30+ command_timeout : " 20m"
31+ script : |
32+ APP_DIR="/home/${{ secrets.USER }} /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+ ~/.local/bin/uv sync
59+
60+ echo "Restarting service..."
61+ sudo systemctl restart act-bot.service
62+ sleep 3
63+ sudo systemctl status act-bot.service --no-pager
0 commit comments