@@ -10,24 +10,28 @@ jobs:
1010 - name : Checkout Code
1111 uses : actions/checkout@v4
1212
13- - name : Deploy to VPS
14- uses : appleboy/scp-action@master
15- with :
16- host : ${{ secrets.SSH_HOST }}
17- username : ${{ secrets.SSH_USER }}
18- key : ${{ secrets.SSH_KEY }}
19- proxy_host : ${{ secrets.SSH_HOST }}
20- proxy_username : " cloudflared"
21- source : " ."
22- target : " /var/www/${{ github.event.repository.name }}"
13+ - name : Install Cloudflared on Runner
14+ run : |
15+ curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared
16+ chmod +x cloudflared
17+ sudo mv cloudflared /usr/local/bin/
2318
24- - name : Execute Build and Restart
25- uses : appleboy/ssh-action@master
26- with :
27- host : ${{ secrets.SSH_HOST }}
28- username : ${{ secrets.SSH_USER }}
29- key : ${{ secrets.SSH_KEY }}
30- script : |
19+ - name : Deploy via Cloudflare Tunnel
20+ run : |
21+ mkdir -p ~/.ssh
22+ echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
23+ chmod 600 ~/.ssh/id_ed25519
24+
25+ cat <<EOF > ~/.ssh/config
26+ Host ${{ secrets.SSH_HOST }}
27+ ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h
28+ EOF
29+
30+ scp -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -r . ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/var/www/${{ github.event.repository.name }}
31+
32+ ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
3133 cd /var/www/${{ github.event.repository.name }}
34+
3235 nixpacks build . --name ${{ github.event.repository.name }}
3336 pm2 restart ${{ github.event.repository.name }} || pm2 start "nixpacks run ." --name ${{ github.event.repository.name }}
37+ EOF
0 commit comments