Skip to content

Commit efe24d9

Browse files
authored
Refactor deployment workflow to use SCP and SSH actions
Removed Cloudflared installation and deployment steps, added direct deployment to VPS using SCP and SSH actions.
1 parent e07235c commit efe24d9

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

.github/workflows/deploy.yml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,24 @@ jobs:
1010
- name: Checkout Code
1111
uses: actions/checkout@v4
1212

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/
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 }}"
1823

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-
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
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: |
3131
cd /var/www/${{ github.event.repository.name }}
32-
33-
git pull origin main
34-
35-
sudo nixpacks build . --name ${{ github.event.repository.name }}
36-
sudo pm2 restart ${{ github.event.repository.name }} || sudo pm2 start "nixpacks run ." --name ${{ github.event.repository.name }}
37-
EOF
32+
nixpacks build . --name ${{ github.event.repository.name }}
33+
pm2 restart ${{ github.event.repository.name }} || pm2 start "nixpacks run ." --name ${{ github.event.repository.name }}

0 commit comments

Comments
 (0)