Skip to content

fix: spec-author checkout 本仓@action_ref(可复用上下文,W0-C4 #133) - #46

Merged
randypanding merged 1 commit into
mainfrom
fix-spec-author-selfcheckout
Aug 21, 2026
Merged

randypanding merged 1 commit into
mainfrom
fix-spec-author-selfcheckout

Conversation

@randypanding

Copy link
Copy Markdown
Contributor

可复用 workflow 在调用方上下文运行:checkout 不带 repository 拉的是调用方仓(.github)——conductor 实调时 pipeline/spec-template.md FileNotFoundError(run 32455589396 spec job)。显式 repository: CI-Workflows + ref: github.action_ref(自引用钉点:被调方永远执行调用方钉定的 SHA;dispatch 时 action_ref=main 分支引用,同样成立)。注:此缺陷 dispatch 自测无法暴露(本仓上下文 checkout 天然正确)——只能 caller 实调发现。

Copilot AI lite review requested due to automatic review settings August 21, 2026 06:56
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@randypanding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Limit details: You’ve used all 10 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b44de34-284f-46df-836c-0c3d9c298e2e

📥 Commits

Reviewing files that changed from the base of the PR and between 81f5457 and e619d51.

📒 Files selected for processing (1)
  • .github/workflows/spec-author.yml

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix spec-author reusable workflow to checkout CI-Workflows at github.action_ref

🐞 Bug fix ⚙️ Configuration changes 🕐 Less than 10 minutes

Grey Divider

AI Description

• Fix reusable workflow checkout defaulting to caller repo and missing spec template file
• Explicitly checkout CI-Workflows repository pinned to caller-selected github.action_ref
• Add inline comments documenting the reusable-workflow context pitfall and pinning rationale
Diagram

graph TD
  A["Caller repo (.github)"] --> B[["Reusable workflow: spec-author"]] --> C["Spec job"] --> D["actions/checkout"] --> E[("CI-Workflows repo")] --> F["spec-template.md"]
  subgraph Legend
    direction LR
    _p["Process/step"] ~~~ _w[["Reusable workflow"]] ~~~ _r[("Repository")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use github.action_repository instead of hardcoding owner/repo
  • ➕ Avoids embedding Cloudbird-Software/CI-Workflows in the workflow
  • ➕ More robust if the repository is forked/renamed
  • ➖ Not all orgs standardize on this context; may be less obvious to readers
  • ➖ Needs validation that the context is available/accurate for reusable workflows in your target runners
2. Bundle required templates as artifacts or embed them in the workflow
  • ➕ Eliminates reliance on cross-repo checkout semantics
  • ➕ Can reduce network checkout time and failure modes
  • ➖ Harder to maintain/version templates alongside the main repo code
  • ➖ Requires additional publishing/packaging steps

Recommendation: The PR’s approach is the right default: explicitly checking out the called repository and pinning to github.action_ref directly addresses the reusable-workflow context trap and guarantees the caller-selected SHA is what executes. If future portability/forking matters, consider switching the hardcoded repository to github.action_repository (if confirmed supported in your environment) to remove the fixed owner/repo string while keeping the same pinning behavior.

Files changed (1) +5 / -0

Bug fix (1) +5 / -0
spec-author.ymlExplicitly checkout CI-Workflows at github.action_ref in reusable workflow +5/-0

Explicitly checkout CI-Workflows at github.action_ref in reusable workflow

• Adds documentation noting that reusable workflows run in the caller context and default checkout pulls the caller repository. Updates the checkout step to explicitly fetch Cloudbird-Software/CI-Workflows at ref github.action_ref to prevent missing pipeline/spec-template.md during real caller runs.

.github/workflows/spec-author.yml

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在修复 spec-author 作为 可复用 workflow 被调用时的运行上下文问题:actions/checkout 默认会拉取 调用方仓库,导致被调方需要的本仓文件(如 pipeline/spec-template.md)在 caller 上下文缺失,从而触发运行时错误。

Changes:

  • spec-author 的首个 actions/checkout 中显式指定 repository: Cloudbird-Software/CI-Workflows
  • 试图通过 ref: ${{ github.action_ref }} 将 checkout 锁定到调用方钉定的版本

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 46 to 50
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: Cloudbird-Software/CI-Workflows
ref: ${{ github.action_ref }}
persist-credentials: false
@randypanding
randypanding merged commit 8c84751 into main Aug 21, 2026
12 of 13 checks passed
@randypanding
randypanding deleted the fix-spec-author-selfcheckout branch August 21, 2026 07:00
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Wrong ref context used 🐞 Bug ≡ Correctness
Description
ref: ${{ github.action_ref }} 取到的是“当前 step 执行的 action 的 ref”,不是可复用 workflow 本身的 SHA,导致 checkout
可能指向不存在于 CI-Workflows 仓的 ref(从而直接失败)或指向错误版本。结果是 pipeline/spec-template.md 等同仓文件读取仍可能失败或出现版本漂移。
Code

.github/workflows/spec-author.yml[R48-49]

+          repository: Cloudbird-Software/CI-Workflows
+          ref: ${{ github.action_ref }}
Relevance

●●● Strong

Deterministic reusable-workflow ref-context bug; later PR#32 pins CI-Workflows checkout with
explicit ref pattern.

PR-#32

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR 新增的 ref: ${{ github.action_ref }} 使用了不适用于可复用 workflow 自检出的上下文变量;GitHub 文档明确 github.action_ref
是“step 执行 action 的 ref”,而可复用 workflow 需要用 job.workflow_repository/job.workflow_sha 来 checkout
定义该 job 的 workflow 文件所在仓库与提交。

.github/workflows/spec-author.yml[43-50]
🌐 文档定义 github.action_ref 为“对执行 action 的 step,这是被执行 action 的 ref”;并给出可复用 workflow checkout 自身源码的示例,使用 job.workflow_repository + job.workflow_sha

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow sets `actions/checkout` `ref` to `${{ github.action_ref }}`, but `github.action_ref` refers to the ref of an action being executed (e.g., the `actions/checkout` action), not the reusable workflow's own pinned revision. This can cause checkout to fail (ref not found in CI-Workflows) or checkout the wrong commit.

## Issue Context
This workflow reads files co-located with the workflow definition (e.g. `pipeline/spec-template.md`), so it must reliably checkout the repository and commit that contains the workflow file being executed.

## Fix Focus Areas
- .github/workflows/spec-author.yml[43-50]

## Suggested change
Replace the hard-coded ref with the reusable-workflow-specific contexts:
- `repository: ${{ job.workflow_repository }}`
- `ref: ${{ job.workflow_sha }}`

(These contexts are designed for reusable workflows to checkout their own source.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Hardcoded repository reduces reuse 🐞 Bug ⚙ Maintainability
Description
将 checkout 仓库硬编码为 Cloudbird-Software/CI-Workflows 会在仓库迁移/改名、或该 workflow 被
fork/镜像复用时直接失效,降低可维护性与可移植性。使用 job.workflow_repository 可在不改变语义(始终 checkout 被调用方仓库)的前提下自动适配。
Code

.github/workflows/spec-author.yml[48]

+          repository: Cloudbird-Software/CI-Workflows
Relevance

●● Moderate

Hardcoding own repo is intentional self-checkout pattern; portability concern lacks close precedent
either way.

PR-#32

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
该 PR 引入了硬编码仓库名;GitHub 提供 job.workflow_repository 以在可复用 workflow 中定位定义 job 的 workflow
所在仓库,从而避免硬编码导致的迁移/复用失效。

.github/workflows/spec-author.yml[46-50]
🌐 文档提供 job.workflow_repository(定义该 job 的 workflow 文件所在 owner/repo)并示例用于可复用 workflow checkout 自身源码。

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The checkout step hardcodes `repository: Cloudbird-Software/CI-Workflows`, which will break if the repo is renamed/migrated or if the workflow is reused from a fork/mirror.

## Issue Context
In reusable workflows, GitHub exposes the repository containing the workflow file via `job.workflow_repository`, which is intended for exactly this use-case.

## Fix Focus Areas
- .github/workflows/spec-author.yml[46-50]

## Suggested change
Replace:
- `repository: Cloudbird-Software/CI-Workflows`
with:
- `repository: ${{ job.workflow_repository }}`

(And pair it with `ref: ${{ job.workflow_sha }}` to ensure the checked-out code matches the pinned workflow revision.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Web pages:
  +6 more
Review mode: ⚖️ Balanced: This is a small but behavior-changing reusable workflow checkout fix affecting repository/ref resolution and caller-context execution, so it warrants a careful single-pass review rather than lite or skip.

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display preferences with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +48 to +49
repository: Cloudbird-Software/CI-Workflows
ref: ${{ github.action_ref }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Wrong ref context used 🐞 Bug ≡ Correctness

ref: ${{ github.action_ref }} 取到的是“当前 step 执行的 action 的 ref”,不是可复用 workflow 本身的 SHA,导致 checkout
可能指向不存在于 CI-Workflows 仓的 ref(从而直接失败)或指向错误版本。结果是 pipeline/spec-template.md 等同仓文件读取仍可能失败或出现版本漂移。
Agent Prompt
## Issue description
The workflow sets `actions/checkout` `ref` to `${{ github.action_ref }}`, but `github.action_ref` refers to the ref of an action being executed (e.g., the `actions/checkout` action), not the reusable workflow's own pinned revision. This can cause checkout to fail (ref not found in CI-Workflows) or checkout the wrong commit.

## Issue Context
This workflow reads files co-located with the workflow definition (e.g. `pipeline/spec-template.md`), so it must reliably checkout the repository and commit that contains the workflow file being executed.

## Fix Focus Areas
- .github/workflows/spec-author.yml[43-50]

## Suggested change
Replace the hard-coded ref with the reusable-workflow-specific contexts:
- `repository: ${{ job.workflow_repository }}`
- `ref: ${{ job.workflow_sha }}`

(These contexts are designed for reusable workflows to checkout their own source.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

# SHA,自引用钉点——被调方永远执行自己被钉定的版本,#143 实测教训)
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: Cloudbird-Software/CI-Workflows

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Hardcoded repository reduces reuse 🐞 Bug ⚙ Maintainability

将 checkout 仓库硬编码为 Cloudbird-Software/CI-Workflows 会在仓库迁移/改名、或该 workflow 被
fork/镜像复用时直接失效,降低可维护性与可移植性。使用 job.workflow_repository 可在不改变语义(始终 checkout 被调用方仓库)的前提下自动适配。
Agent Prompt
## Issue description
The checkout step hardcodes `repository: Cloudbird-Software/CI-Workflows`, which will break if the repo is renamed/migrated or if the workflow is reused from a fork/mirror.

## Issue Context
In reusable workflows, GitHub exposes the repository containing the workflow file via `job.workflow_repository`, which is intended for exactly this use-case.

## Fix Focus Areas
- .github/workflows/spec-author.yml[46-50]

## Suggested change
Replace:
- `repository: Cloudbird-Software/CI-Workflows`
with:
- `repository: ${{ job.workflow_repository }}`

(And pair it with `ref: ${{ job.workflow_sha }}` to ensure the checked-out code matches the pinned workflow revision.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

2 participants