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