This commit is contained in:
weichengwu 2025-11-17 10:36:27 +08:00
parent ef9eabb880
commit 03cee79b53
1 changed files with 49 additions and 0 deletions

49
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Deploy to Server
on:
push:
branches: [main]
workflow_dispatch: {}
jobs:
build:
runs-on:
labels: mac-mini-2018
env:
APP_NAME: fucai-claim
BUILD_NAME: fucai-claim-${{ github.run_number }}-${{ github.sha }}
SSH_USER: root
SSH_HOST: 123.60.153.169
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install deps & Build site
run: |
corepack enable
pnpm install --frozen-lockfile
pnpm build
- name: Archive dist
run: |
tar -czf ${{ env.BUILD_NAME }}.tar.gz -C dist .
- name: Upload to server
run: |
scp ${{ env.BUILD_NAME }}.tar.gz ${{ env.SSH_USER }}@${{ env.SSH_HOST }}:/tmp/
- name: Remote deploy
run: |
ssh ${{ env.SSH_USER }}@${{ env.SSH_HOST }} <<'SH'
set -e
cd /var/www/
rm -rf ${{ env.APP_NAME }}
mkdir -p ${{ env.APP_NAME }}
tar -xzf /tmp/${{ env.BUILD_NAME }}.tar.gz -C ${{ env.APP_NAME }}
rm /tmp/${{ env.BUILD_NAME }}.tar.gz
SH