Skip to content

refactor(ci): extract repo config as env vars in CI examples#195

Closed
m0Nst3r873 wants to merge 10 commits into
Tencent:mainfrom
m0Nst3r873:worktree-ci-repo-env-vars
Closed

refactor(ci): extract repo config as env vars in CI examples#195
m0Nst3r873 wants to merge 10 commits into
Tencent:mainfrom
m0Nst3r873:worktree-ci-repo-env-vars

Conversation

@m0Nst3r873

Copy link
Copy Markdown
Collaborator

Summary

  • CI example 文件中的仓库路径、默认分支、AI 网关地址等硬编码占位符统一提取为 env: 块中的环境变量
  • 新增 TEAMAI_KNOWLEDGE_REPOTEAMAI_KNOWLEDGE_BRANCHANTHROPIC_AUTH_TOKEN 等变量声明
  • 用户只需修改 env: 顶部配置,无需在 YAML 中搜索散落的占位符

Test plan

  • 确认 Coding CI YAML 语法正确(env: 格式、secret: vs value: 语法)
  • 确认 GitHub Actions YAML 语法正确(${{ vars.* }} / ${{ env.* }} 引用)
  • 确认 git clone -b 命令拼接环境变量正确

🤖 Generated with Claude Code

jaelgeng and others added 10 commits July 17, 2026 12:15
--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
QCI does not provide CI_MERGE_REQUEST_URL. Build the MR URL from
QCI_REPO and QCI_MR_IID instead, and skip gracefully when triggered
manually (QCI_MR_IID is empty).

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
QCI sets MR variables to the string "None" (not empty) when triggered
manually. Check for both empty and "None" to skip gracefully.

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Users must fill these in; placeholder strings cause confusing errors.

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Key fixes:
- Use .netrc for TGit auth instead of teamai init
- Remove task-level when: conditions, use script-level checks
- Install @anthropic-ai/claude-code alongside teamai-cli
- Add proper mr: config (action, is_local_mr, auto_cancel)
- Check QCI_TRIGGER_TYPE + QCI_MR_ACTION in script

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
teamai-cli uses gf CLI as the primary method to fetch TGit MR data.
The REST API fallback also requires the OAuth token from gf's
credential store. Without gf CLI installed, both paths fail with 401.

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
teamai init prompts for team repo interactively, which fails in CI.
Pass --repo flag with TEAMAI_KNOWLEDGE_REPO to skip the prompt.

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Short paths like "team/repo" are mistakenly detected as GitHub repos.
Using the full https://git.woa.com/ URL forces TGit provider detection.

--other=0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@m0Nst3r873

Copy link
Copy Markdown
Collaborator Author

Superseded by #210.

#210 folds in this PR's CI-example refactor (top-level env: block + the GitHub-Actions example) and reconciles it with the actual root-cause fix: the pipeline was failing because TGit REST calls used Authorization: Bearer, but a git.woa.com PAT only authenticates via PRIVATE-TOKEN (verified live → Bearer 401/403). The example YAML alone couldn't fix that. #210 also renames the TGit token TAI_PAT_TOKENTGIT_TOKEN to match the code, so the examples here needed that update to keep working.

Closing in favor of #210.

@m0Nst3r873 m0Nst3r873 closed this Jul 20, 2026
m0Nst3r873 added a commit to m0Nst3r873/teamai-cli that referenced this pull request Jul 20, 2026
The TeamAI MR knowledge-extract CI pipeline failed on every run because
TGit REST calls sent `Authorization: Bearer`, but a git.woa.com Personal
Access Token only authenticates via `PRIVATE-TOKEN`/`private_token`
(Bearer → 401/403). Verified live against git.woa.com/api/v3.

Changes:
- Add src/providers/tgit/rest-auth.ts: centralized tgitFetch() that uses
  PRIVATE-TOKEN for a PAT (TGIT_TOKEN env) and Bearer for an OAuth token
  (~/.netrc), with a one-shot 401/403 scheme fallback + process cache.
- Rewrite mr-fetch.ts to REST-only: the gf CLI has no `mr desc`/`mr diff`
  commands and cannot return a diff. Fix diff endpoint to singular
  merge_request/{globalId}/changes, read files[]/changes[], fall back
  merged_at → resolved_at → updated_at, and fix an always-true MR match.
- Route all TGit REST callers (gf-cli, mr-comment, read-rejections,
  extract-mr, gf-org, mr-hint) through the helper.
- Rename the TGit token env var TAI_PAT_TOKEN → TGIT_TOKEN (TGit usages
  only; iWiki's TAI_PAT_TOKEN is a different token and is left untouched).
- CI examples: consolidate repo config into a top-level env block and add
  the github-actions example (supersedes PR Tencent#195), reconciled to TGIT_TOKEN.
- Add rest-auth unit tests; make the gf-org no-credentials test env-independent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
m0Nst3r873 added a commit to m0Nst3r873/teamai-cli that referenced this pull request Jul 20, 2026
The TeamAI MR knowledge-extract CI pipeline failed on every run because
TGit REST calls sent `Authorization: Bearer`, but a git.woa.com Personal
Access Token only authenticates via `PRIVATE-TOKEN`/`private_token`
(Bearer → 401/403). Verified live against git.woa.com/api/v3.

Changes:
- Add src/providers/tgit/rest-auth.ts: centralized tgitFetch() that uses
  PRIVATE-TOKEN for a PAT (TGIT_TOKEN env) and Bearer for an OAuth token
  (~/.netrc), with a one-shot 401/403 scheme fallback + process cache.
- Rewrite mr-fetch.ts to REST-only: the gf CLI has no `mr desc`/`mr diff`
  commands and cannot return a diff. Fix diff endpoint to singular
  merge_request/{globalId}/changes, read files[]/changes[], fall back
  merged_at → resolved_at → updated_at, and fix an always-true MR match.
- Route all TGit REST callers (gf-cli, mr-comment, read-rejections,
  extract-mr, gf-org, mr-hint) through the helper.
- Rename the TGit token env var TAI_PAT_TOKEN → TGIT_TOKEN (TGit usages
  only; iWiki's TAI_PAT_TOKEN is a different token and is left untouched).
- CI examples: consolidate repo config into a top-level env block and add
  the github-actions example (supersedes PR Tencent#195), reconciled to TGIT_TOKEN.
- Add rest-auth unit tests; make the gf-org no-credentials test env-independent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jeff-r2026 pushed a commit that referenced this pull request Jul 20, 2026
…EN (#210)

The TeamAI MR knowledge-extract CI pipeline failed on every run because
TGit REST calls sent `Authorization: Bearer`, but a git.woa.com Personal
Access Token only authenticates via `PRIVATE-TOKEN`/`private_token`
(Bearer → 401/403). Verified live against git.woa.com/api/v3.

Changes:
- Add src/providers/tgit/rest-auth.ts: centralized tgitFetch() that uses
  PRIVATE-TOKEN for a PAT (TGIT_TOKEN env) and Bearer for an OAuth token
  (~/.netrc), with a one-shot 401/403 scheme fallback + process cache.
- Rewrite mr-fetch.ts to REST-only: the gf CLI has no `mr desc`/`mr diff`
  commands and cannot return a diff. Fix diff endpoint to singular
  merge_request/{globalId}/changes, read files[]/changes[], fall back
  merged_at → resolved_at → updated_at, and fix an always-true MR match.
- Route all TGit REST callers (gf-cli, mr-comment, read-rejections,
  extract-mr, gf-org, mr-hint) through the helper.
- Rename the TGit token env var TAI_PAT_TOKEN → TGIT_TOKEN (TGit usages
  only; iWiki's TAI_PAT_TOKEN is a different token and is left untouched).
- CI examples: consolidate repo config into a top-level env block and add
  the github-actions example (supersedes PR #195), reconciled to TGIT_TOKEN.
- Add rest-auth unit tests; make the gf-org no-credentials test env-independent.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
m0Nst3r873 added a commit to m0Nst3r873/teamai-cli that referenced this pull request Jul 20, 2026
The TeamAI MR knowledge-extract CI pipeline failed on every run because
TGit REST calls sent `Authorization: Bearer`, but a git.woa.com Personal
Access Token only authenticates via `PRIVATE-TOKEN`/`private_token`
(Bearer → 401/403). Verified live against git.woa.com/api/v3.

Changes:
- Add src/providers/tgit/rest-auth.ts: centralized tgitFetch() that uses
  PRIVATE-TOKEN for a PAT (TGIT_TOKEN env) and Bearer for an OAuth token
  (~/.netrc), with a one-shot 401/403 scheme fallback + process cache.
  Also tgitGitUser()/tryGetTGitToken() for git-over-HTTPS auth.
- Rewrite mr-fetch.ts to REST-only: the gf CLI has no `mr desc`/`mr diff`
  commands and cannot return a diff. Fix diff endpoint to singular
  merge_request/{globalId}/changes, read files[]/changes[], fall back
  merged_at → resolved_at → updated_at, and fix an always-true MR match.
- Route all TGit REST callers through the helper.
- Fix git-over-HTTPS clone for a PAT: a PAT authenticates git as username
  `private`, an OAuth token as `oauth2`. gfRepoClone now uses token-based
  `git clone` with the scheme-derived username for all repos when a token
  is present, falling back to `gf repo clone` only when no token exists
  (the interactive path). clone.ts uses the same scheme-based username.
  init.ts no longer treats a "repo already exists" create error as fatal.
- Rename the TGit token env var TAI_PAT_TOKEN → TGIT_TOKEN (TGit usages
  only; iWiki's TAI_PAT_TOKEN is a different token and is left untouched).
- CI examples: consolidate repo config into a top-level env block, add the
  github-actions example (supersedes PR Tencent#195), use `private:` for git auth.
- Add rest-auth unit tests (auth scheme, git username, token resolution).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant