调整流水线

This commit is contained in:
2026-04-16 13:41:36 +08:00
parent 8154de452b
commit 5037d83b3d

View File

@@ -4,6 +4,7 @@
# Node请在 Runner 上预装 Node 20+(勿用 actions/setup-node避免每次从 GitHub 拉包)。
# npm通过 npm_registry 输入使用国内镜像(默认 npmmirror
# Checkout不用 actions/checkouthost 模式下 JS Action 仍会进无 Node 的容器);改用 git + github.token。
# 浅拉不要用「裸 SHA」作 fetch 参数Gitea 上易失败);按分支 clone 再对齐 SHA。
name: Reusable Frontend Deploy
@@ -50,19 +51,17 @@ jobs:
git config --global --add safe.directory '*'
REPO="${{ github.repository }}"
SHA="${{ github.sha }}"
BRANCH="${{ github.ref_name }}"
URL="https://x-access-token:${GITEA_TOKEN}@${GITEA_HOST}/${REPO}.git"
WS="${GITHUB_WORKSPACE:-$(pwd)}"
cd "$WS"
if [ -d .git ]; then
git remote set-url origin "$URL" || { git remote remove origin 2>/dev/null || true; git remote add origin "$URL"; }
else
shopt -s dotglob nullglob || true
rm -rf ./* ./.??* 2>/dev/null || true
git init
git remote add origin "$URL"
git clone --depth 1 --branch "$BRANCH" "$URL" .
if [ "$(git rev-parse HEAD)" != "$SHA" ]; then
git fetch --depth 200 origin "refs/heads/${BRANCH}"
git checkout --force "$SHA"
fi
git fetch --depth 1 origin "$SHA"
git checkout --force FETCH_HEAD
- name: Check Node.js (pre-installed on runner)
run: |
@@ -91,8 +90,8 @@ jobs:
cp -a dist/. "$DEST/"
- name: Set ownership for Nginx (Baota www)
if: ${{ inputs.chown_www }}
run: |
case "${{ inputs.chown_www }}" in false|False|"false") exit 0 ;; esac
DEST="${{ inputs.deploy_path }}"
DEST="${DEST%/}"
chown -R www:www "$DEST" || chown -R nginx:nginx "$DEST" || true