Files
photography/.gitea/workflows/deploy-frontend.yml
xujiang 400383d5cb
All checks were successful
Deploy Frontend / deploy (push) Successful in 2m34s
触发ci
2025-07-09 09:54:37 +08:00

78 lines
2.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy Frontend
on:
push:
branches: [ main ]
paths: [ 'frontend/**' ]
pull_request:
branches: [ main ]
paths: [ 'frontend/**' ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: |
cd frontend
bun install
- name: Run type check
run: |
cd frontend
bun run type-check
- name: Run lint
run: |
cd frontend
bun run lint
- name: Build project
run: |
cd frontend
bun run build
- name: Deploy to VPS
run: |
# 安装 SSH 客户端、rsync 和 sshpass
sudo apt-get update && sudo apt-get install -y openssh-client rsync sshpass
# 设置 SSH 选项以禁用主机密钥检查(用于密码认证)
export SSHPASS=${{ secrets.ALIYUN_PWD }}
# 测试 SSH 连接
sshpass -e ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 ${{ secrets.ALIYUN_USER_NAME }}@${{ secrets.ALIYUN_IP }} "echo 'SSH 连接成功'"
# 在服务器上创建用户目录下的部署目录
sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.ALIYUN_USER_NAME }}@${{ secrets.ALIYUN_IP }} "mkdir -p ~/www/photography"
# 上传构建文件到服务器用户目录(使用密码认证)
sshpass -e rsync -avz --delete --progress -e "ssh -o StrictHostKeyChecking=no" frontend/out/ ${{ secrets.ALIYUN_USER_NAME }}@${{ secrets.ALIYUN_IP }}:~/www/photography/
# 设置文件权限(用户目录无需 sudo
sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.ALIYUN_USER_NAME }}@${{ secrets.ALIYUN_IP }} "chmod -R 755 ~/www/photography"
# 显示部署信息Caddy 配置需要手动配置指向新路径)
sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.ALIYUN_USER_NAME }}@${{ secrets.ALIYUN_IP }} "echo '提示:请确保 Web 服务器配置指向 ~/www/photography/ 目录'"
echo "✅ 部署完成!"
echo "📁 部署路径:~/www/photography/"
echo "🌐 访问地址http://photography.iriver.top"
- name: Notify success
if: success()
run: |
echo "✅ 前端项目部署成功!"
- name: Notify failure
if: failure()
run: |
echo "❌ 前端项目部署失败!"