Files
astro-MyBlog/.gitea/workflows/deploy.yml
Marvin-March a58d6db78f
All checks were successful
自动构建并部署Astro博客 / build-and-deploy (push) Successful in 39s
fix: change value of source again
2026-04-22 11:43:24 +08:00

43 lines
1.1 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: 自动构建并部署Astro博客
# 触发条件main分支有代码推送时执行
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 1. 拉取仓库最新代码
- name: 检出代码
uses: actions/checkout@v4
with:
fetch-depth: 0
# 2. 安装Node.js 20Astro运行环境
- name: 安装Node.js
uses: actions/setup-node@v4
with:
node-version: 22
env:
NODEJS_ORG_MIRROR: https://npmmirror.com/mirrors/node
# 3. 安装依赖 + 打包Astro项目生成dist目录
- name: 安装依赖并构建
run: |
npm install
npm run build
# 4. 把打包好的dist文件同步到服务器Apache目录
- name: 同步到服务器
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
port: ${{ secrets.SERVER_PORT }}
key: ${{ secrets.SERVER_SSH_KEY }}
source: "dist/*"
target: "/var/www/blog/"
overwrite: true
rm: true