From ab6ff0cdae7d99336a18da4d9617860e7fde0724 Mon Sep 17 00:00:00 2001 From: Marvin Date: Wed, 15 Apr 2026 14:18:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E7=9A=84workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy.yml | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..de7be10 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,41 @@ +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 20(Astro运行环境) + - name: 安装Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + # 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 \ No newline at end of file