Files
lixi 8330885b06
CI / backend-test (push) Successful in 6m47s
chore: 凭证防泄漏检查落地——check-secrets 脚本入库 + CI 兜底 step(ADR-021)
- 新增 scripts/check-secrets.sh:8 条内容规则 + 文件名黑名单 + 占位/注入允许清单,纯 shell 零外部依赖
- 新增 scripts/hooks/pre-commit:git config core.hooksPath scripts/hooks 启用,扫暂存区
- ci.yml 在 checkout 后新增 Secret scan step(同一脚本 --all),既有 step 未动
- 验收:全仓 194 个已跟踪文件扫描零误报;构造假 AK/SK/私钥/.env 自测 9 类命中全拦截

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-08 16:28:04 +08:00

56 lines
2.9 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Gitea Actions 门禁:与 docs/development/git-workflow.md 的本地门禁完全同一条命令。
#
# 启用前提(服务器侧,一次性):
# 1. Gitea ≥ 1.19 且管理端开启 Actionsapp.ini: [actions] ENABLED=true
# 仓库 Settings → Actions 启用)。
# 2. 注册一个 act_runner,且 runner 所在主机具备:
# - DockerTestcontainers 需要,跑 postgres:18 一次性容器)
# - 标签 ubuntu-latest 映射到含 bash/git 的镜像,或 host 模式执行
# 3. 服务器无法访问 github.com:本工作流不引用任何外部 action——
# checkout 手动从本 Gitea 实例克隆,JDK 用 apt 安装,全链路无 GitHub 依赖。
#
# 未启用 Actions 时本文件无副作用。
name: CI
on:
push:
branches: [dev]
pull_request:
# 同分支连推多个提交时,自动取消旧的排队/进行中 run,只跑最新
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
backend-test:
runs-on: ubuntu-latest
steps:
# 不用 actions/checkoutGitea 1.20+ 的 DEFAULT_ACTIONS_URL 仅接受
# github/self,自定义镜像源不生效,action 会回落到 github.com(服务器不可达)。
# 改为手动从本 Gitea 实例克隆,零外部依赖。
- name: Checkout (manual)
run: |
git init -q .
AUTH_URL=$(echo "${{ github.server_url }}" | sed "s#https://#https://oauth2:${{ github.token }}@#")
git remote add origin "$AUTH_URL/${{ github.repository }}.git"
git fetch -q --depth 1 origin "+${{ github.ref }}:refs/ci-head"
git checkout -q refs/ci-head
# 凭证防泄漏兜底(ADR-021):与本地 pre-commit 同一脚本、同一规则表,
# 扫全部已跟踪文件(覆盖本次 push 变更的超集),纯 shell 零外部依赖。
- name: Secret scan
run: sh scripts/check-secrets.sh --all
# 不用 actions/setup-java:它从 github.com 下载 JDK 二进制,
# 服务器无法访问 GitHub(实测 ETIMEDOUT)。改用 apt 装 OpenJDK 17
# 并优先切换到腾讯云镜像源(runner 在腾讯云,内网加速)。
- name: Install JDK 17 via apt
run: |
sed -i 's|http://archive.ubuntu.com|https://mirrors.cloud.tencent.com|g; s|http://security.ubuntu.com|https://mirrors.cloud.tencent.com|g' /etc/apt/sources.list 2>/dev/null || true
sed -i 's|http://archive.ubuntu.com|https://mirrors.cloud.tencent.com|g; s|http://security.ubuntu.com|https://mirrors.cloud.tencent.com|g' /etc/apt/sources.list.d/*.sources 2>/dev/null || true
apt-get update -qq
apt-get install -y -qq --no-install-recommends openjdk-17-jdk-headless
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" >> "$GITHUB_ENV"
java -version
# 与本地门禁同一命令;BUILD SUCCESS 且 0 失败方可合入(git-workflow.md
- run: ./mvnw -B clean test