fix(release): use tracked dashboard dist for offline deploys
This commit is contained in:
@@ -56,34 +56,18 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
toolchain_root="${MAIBOT_NODE_TOOLCHAIN_ROOT:-/srv/gitea-runner-maibot/toolchains/node}"
|
||||
dist_bundle_root="${MAIBOT_PREBUILT_DASHBOARD_ROOT:-/srv/gitea-runner-maibot/prebuilt-dashboard}"
|
||||
commit_sha="${APP_TAG:-$(git -C "$MAIBOT_WORKTREE" rev-parse --short=10 HEAD)}"
|
||||
dist_bundle="${dist_bundle_root}/${commit_sha}.tar.gz"
|
||||
|
||||
if [ -d "$toolchain_root/bin" ]; then
|
||||
export PATH="$toolchain_root/bin:$PATH"
|
||||
fi
|
||||
|
||||
cd "$MAIBOT_WORKTREE/dashboard"
|
||||
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
if [ -f dist/index.html ]; then
|
||||
echo "Using tracked dashboard/dist from repository"
|
||||
elif command -v npm >/dev/null 2>&1; then
|
||||
npm_cache_dir="${MAIBOT_NPM_CACHE_DIR:-/srv/gitea-runner-maibot/npm-cache}"
|
||||
mkdir -p "$npm_cache_dir"
|
||||
npm ci --cache "$npm_cache_dir"
|
||||
npm run build
|
||||
fi
|
||||
|
||||
if [ ! -f dist/index.html ] && [ -f "$dist_bundle" ]; then
|
||||
echo "Using prebuilt dashboard bundle: $dist_bundle"
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
tar -xzf "$dist_bundle" -C "$MAIBOT_WORKTREE/dashboard"
|
||||
fi
|
||||
|
||||
if [ ! -f dist/index.html ]; then
|
||||
echo "dashboard build output not found: $MAIBOT_WORKTREE/dashboard/dist/index.html" >&2
|
||||
echo "Provide a working offline npm toolchain or upload a prebuilt dashboard bundle to $dist_bundle." >&2
|
||||
else
|
||||
echo "dashboard/dist is missing and npm is unavailable on the runner." >&2
|
||||
echo "For this offline workflow, commit dashboard/dist into the repository before releasing." >&2
|
||||
exit 127
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user