Skip to content

Commit b6ec197

Browse files
authored
Update deployment process to use Cloudflare Tunnel
Replaced direct deployment steps with Cloudflare Tunnel for secure access.
1 parent efe24d9 commit b6ec197

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

.github/workflows/deploy.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)