fix(ci): Preflight 直接跑 docker://node:22-bookworm-slim 跳过 setup-node 下载(国内 GitHub release 超时)
This commit is contained in:
+24
-18
@@ -39,7 +39,9 @@ jobs:
|
||||
# ============================================================
|
||||
preflight:
|
||||
name: Preflight 语法 & 构建检查
|
||||
runs-on: ubuntu-latest
|
||||
# 国内访问 GitHub actions/node-versions release 经常超时(443 ETIMEDOUT)
|
||||
# 所以直接用官方 node:22 镜像跑这个 Job,绕过 setup-node 下载 step
|
||||
runs-on: [ubuntu-latest:docker://node:22-bookworm-slim]
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- name: 📥 Checkout 代码
|
||||
@@ -47,11 +49,15 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: 🔧 安装 Node.js 22
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "npm"
|
||||
# ── 我们已经用 runs-on: docker://node:22 了,所以这里不需要 actions/setup-node ──
|
||||
# 避免国内 Runner 从 github.com 下载 Node tar.gz 出现 ETIMEDOUT
|
||||
- name: 🔎 环境自检(node/npm 版本)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
node -v
|
||||
npm -v
|
||||
which node npm
|
||||
|
||||
- name: 🧪 安装依赖(npm ci,严格按锁文件)
|
||||
run: |
|
||||
@@ -92,12 +98,12 @@ jobs:
|
||||
image_full: ${{ steps.meta.outputs.full }}
|
||||
image_latest: ${{ steps.meta.outputs.latest }}
|
||||
steps:
|
||||
- name: 📥 Checkout 代码
|
||||
- name: Checkout 代码
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: 🏷️ 计算镜像 tag(日期 + 短 SHA)
|
||||
- name: 计算镜像 tag(日期 + 短 SHA)
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -116,17 +122,17 @@ jobs:
|
||||
echo "🪪 镜像 latest : ${IMG_LATEST}"
|
||||
echo "======================================"
|
||||
|
||||
- name: 🔧 启用 QEMU(跨架构小概率用得到,保险)
|
||||
- name: 启用 QEMU(跨架构小概率用得到,保险)
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
|
||||
- name: 🔧 启用 Docker Buildx
|
||||
- name: 启用 Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: 🔐 登录 Gitea 容器仓库(Packages)
|
||||
- name: 登录 Gitea 容器仓库(Packages)
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.GITEA_HOST }}
|
||||
@@ -135,7 +141,7 @@ jobs:
|
||||
# Secrets 里 REGISTRY_TOKEN 优先,没填就用 Gitea Actions 自动注入的仓库级 token
|
||||
password: ${{ secrets.REGISTRY_TOKEN || github.token }}
|
||||
|
||||
- name: 🐳 构建 & 推送(BuildKit 分层缓存,skip_build_cache=true 时禁用)
|
||||
- name: 构建 & 推送(BuildKit 分层缓存,skip_build_cache=true 时禁用)
|
||||
id: build_push
|
||||
uses: docker/build-push-action@v6
|
||||
env:
|
||||
@@ -159,7 +165,7 @@ jobs:
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
|
||||
|
||||
- name: 🧮 镜像体积 & 层信息(日志里看一下,避免镜像越来越大)
|
||||
- name: 镜像体积 & 层信息(日志里看一下,避免镜像越来越大)
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
docker pull "${{ steps.meta.outputs.full }}" || true
|
||||
@@ -181,7 +187,7 @@ jobs:
|
||||
name: production
|
||||
url: ${{ secrets.NUXT_PUBLIC_SITE_URL }}
|
||||
steps:
|
||||
- name: ⚠️ 检查部署所需 Secrets 是否都配置了
|
||||
- name: 检查部署所需 Secrets 是否都配置了
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -196,7 +202,7 @@ jobs:
|
||||
fi
|
||||
echo "✅ 部署 Secrets 配置完整"
|
||||
|
||||
- name: 🚀 一键滚动部署(SSH)
|
||||
- name: 一键滚动部署(SSH)
|
||||
uses: appleboy/ssh-action@v1.2.0
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
@@ -217,9 +223,9 @@ jobs:
|
||||
COMPOSE="docker compose"
|
||||
|
||||
echo "=============================================="
|
||||
echo "🚢 本次部署镜像: ${IMAGE_NEW}"
|
||||
echo "🗂️ 部署目录 : ${DEPLOY_DIR}"
|
||||
echo "👤 执行用户 : $(whoami)"
|
||||
echo "本次部署镜像: ${IMAGE_NEW}"
|
||||
echo "部署目录 : ${DEPLOY_DIR}"
|
||||
echo "执行用户 : $(whoami)"
|
||||
echo "=============================================="
|
||||
|
||||
# ---------- 1. 确保部署目录存在 ----------
|
||||
|
||||
Reference in New Issue
Block a user