fix(ci): 兼容精简 runner(Alpine)环境
- checkout 改为原生 git 浅克隆(action-checkout 依赖 node,Alpine runner 无) - 发布 release 改用 grep/sed 解析 JSON(不依赖 python3) - 小程序密钥 PEM 规整改用 node 实现 - 通知步骤增加容错(失败不阻断主流程)
This commit is contained in:
@@ -14,10 +14,14 @@ jobs:
|
||||
# 标准标签:hk / bt-runner 均带 ubuntu-latest,任一空闲 runner 接单
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
|
||||
with:
|
||||
# Need recent commit subjects for the WeChat upload remark.
|
||||
fetch-depth: 20
|
||||
# 精简 runner(Alpine)无 node,无法跑 action-checkout;直接用 git 浅克隆
|
||||
- name: Checkout
|
||||
run: |
|
||||
git init -q .
|
||||
git remote add origin "$GITEA_SERVER_URL/$GITEA_REPOSITORY"
|
||||
git fetch -q --depth 20 origin "$GITEA_REF_NAME"
|
||||
git checkout -q FETCH_HEAD
|
||||
git log --oneline -3
|
||||
|
||||
- name: Prepare Node toolchain
|
||||
run: |
|
||||
@@ -116,19 +120,17 @@ jobs:
|
||||
node -e 'const {resolveVersion}=require("./ci/resolve-version.cjs"); console.log("Resolved Mini Program version:", resolveVersion(process.cwd()))'
|
||||
node -e 'const {resolveUploadDesc}=require("./ci/resolve-upload-desc.cjs"); console.log("Resolved upload remark:", resolveUploadDesc({repoRoot:require("path").resolve(".."), versionLabel:process.env.MINIAPP_VERSION_LABEL}))'
|
||||
# Normalize PEM newlines that may be flattened when stored in Secrets.
|
||||
python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
import os
|
||||
key_path = Path(os.environ["WECHAT_CI_PRIVATE_KEY_PATH"])
|
||||
text = key_path.read_text()
|
||||
if "\\n" in text and "BEGIN" in text:
|
||||
text = text.replace("\\n", "\n")
|
||||
text = text.replace("\r\n", "\n").strip() + "\n"
|
||||
key_path.write_text(text)
|
||||
content = key_path.read_text()
|
||||
assert "BEGIN" in content and "PRIVATE KEY" in content, "WECHAT_CI_PRIVATE_KEY is not a PEM private key"
|
||||
print("private_key_lines=", len(content.splitlines()))
|
||||
PY
|
||||
# 用 node 处理(部分 runner 无 python3)
|
||||
node - <<'JS'
|
||||
const fs = require("fs");
|
||||
const p = process.env.WECHAT_CI_PRIVATE_KEY_PATH;
|
||||
let t = fs.readFileSync(p, "utf8");
|
||||
if (t.includes("\\n") && t.includes("BEGIN")) t = t.split("\\n").join("\n");
|
||||
t = t.split("\r\n").join("\n").trim() + "\n";
|
||||
fs.writeFileSync(p, t);
|
||||
if (!/PRIVATE KEY/.test(t)) { console.error("WECHAT_CI_PRIVATE_KEY is not a PEM private key"); process.exit(1); }
|
||||
console.log("private_key_lines=", t.split("\n").length);
|
||||
JS
|
||||
node ci/upload-ci.cjs
|
||||
test -s ci-artifacts/upload-result.json
|
||||
cat ci-artifacts/upload-result.json
|
||||
@@ -141,7 +143,7 @@ jobs:
|
||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
run: |
|
||||
VERSION="$(tr -d '\n' < mini/ci-artifacts/resolved-version.txt)"
|
||||
bash .gitea/scripts/notify.sh success "小程序开发版上传成功" "版本: ${VERSION}"
|
||||
bash .gitea/scripts/notify.sh success "小程序开发版上传成功" "版本: ${VERSION}" || echo "通知发送失败,不影响主流程"
|
||||
|
||||
- name: Send failure notification
|
||||
if: failure()
|
||||
@@ -152,7 +154,7 @@ jobs:
|
||||
run: |
|
||||
bash .gitea/scripts/notify.sh failure \
|
||||
"小程序开发版上传失败" \
|
||||
"请检查 Actions 日志了解失败原因"
|
||||
"请检查 Actions 日志了解失败原因" || echo "通知发送失败"
|
||||
|
||||
- name: Remove temporary credentials
|
||||
if: always()
|
||||
|
||||
Reference in New Issue
Block a user