调整流水线
This commit is contained in:
19
.github/workflows/reusable-release-frontend.yaml
vendored
19
.github/workflows/reusable-release-frontend.yaml
vendored
@@ -4,6 +4,7 @@
|
||||
# Node:请在 Runner 上预装 Node 20+(勿用 actions/setup-node,避免每次从 GitHub 拉包)。
|
||||
# npm:通过 npm_registry 输入使用国内镜像(默认 npmmirror)。
|
||||
# Checkout:不用 actions/checkout(host 模式下 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"
|
||||
shopt -s dotglob nullglob || true
|
||||
rm -rf ./* ./.??* 2>/dev/null || true
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user