Skip to content

.github/workflows/main.yml #458

.github/workflows/main.yml

.github/workflows/main.yml #458

Workflow file for this run

on:
workflow_dispatch:
repository_dispatch:
types:
- update
schedule:
- cron: '0 2 * * *'
jobs:
build_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set Node.js 20.x
uses: actions/setup-node@master
with:
node-version: 20.x
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install` command
- name: Build production bundle
uses: borales/actions-yarn@v4
env:
FLUX_TOKEN: ${{secrets.FLUX_TOKEN}}
with:
cmd: prod # will run `yarn prod` command
- name: Install rsync
run: sudo apt-get install -y rsync
- name: Deploy to VPS
env:
VPS_HOST: ${{ secrets.VPS_HOST }}
VPS_PORT: ${{ secrets.VPS_PORT }}
VPS_USER: ${{ secrets.VPS_USER }}
VPS_SSH_PRIVATE_KEY: ${{ secrets.VPS_SSH_PRIVATE_KEY }}
run: |
# 创建 SSH 目录
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# 将私钥写入文件
echo "$VPS_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# 启用 SSH 公钥验证
echo "StrictHostKeyChecking no" >> ~/.ssh/config
# 使用 rsync 部署文件
rsync -avz --delete -e "ssh -p $VPS_PORT" dist/ $VPS_USER@$VPS_HOST:/var/11ty-data