mirror of
https://github.com/handsomezhuzhu/handsomezhuzhu.github.io.git
synced 2026-02-20 20:00:14 +00:00
linuxdo图片优化和部署调整
This commit is contained in:
108
.github/workflows/deploy.yml
vendored
108
.github/workflows/deploy.yml
vendored
@@ -97,111 +97,3 @@
|
||||
# - name: Deploy to GitHub Pages
|
||||
# id: deployment
|
||||
# uses: actions/deploy-pages@v4
|
||||
name: Deploy to 1Panel & GitHub Pages
|
||||
|
||||
# ===========================
|
||||
# 触发条件
|
||||
# ===========================
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
# 设置时区
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
# 权限设置
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22]
|
||||
|
||||
steps:
|
||||
# 1. 拉取代码
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# 2. 设置 Node.js
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
# 3. 安装依赖 (npm)
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
# 4. 构建项目
|
||||
- name: Build blog project
|
||||
run: npm run build
|
||||
|
||||
# --------------------------------------------------
|
||||
# 分支任务 A: 部署到 1Panel (路径已修改)
|
||||
# --------------------------------------------------
|
||||
- name: Deploy to 1Panel via SCP
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
|
||||
# 源文件 (保持不变)
|
||||
source: "docs/.vitepress/dist/*"
|
||||
|
||||
# 【关键修改】目标路径改为 1Panel 指定的路径
|
||||
# 注意:这里假设你在 1Panel 创建网站时,代号填的是 "blog"
|
||||
target: "/opt/1panel/apps/openresty/openresty/www/sites/blog/index"
|
||||
|
||||
# 去掉路径前缀
|
||||
strip_components: 3
|
||||
|
||||
- name: Fix 1Panel Permissions
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
script: |
|
||||
# 【关键修改】修复新路径的权限
|
||||
# 1Panel 容器通常使用 1000:1000 作为 www 用户
|
||||
chown -R 1000:1000 /opt/1panel/apps/openresty/openresty/www/sites/blog/index
|
||||
|
||||
# --------------------------------------------------
|
||||
# 准备分支任务 B: 为 GitHub Pages 上传构建产物
|
||||
# --------------------------------------------------
|
||||
- name: Upload artifact for GitHub Pages
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: docs/.vitepress/dist
|
||||
|
||||
# ==================================================
|
||||
# 任务 2: 部署到 GitHub Pages
|
||||
# ==================================================
|
||||
deploy-gh-pages:
|
||||
needs: build
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
Reference in New Issue
Block a user