fix: checkout main branch for docs deployment on release#326
Conversation
Release events use the tag ref (e.g. 2.0.0) which is rejected by the github-pages environment branch protection rules. Always checkout main to ensure docs are deployed from the default branch.
📝 WalkthroughWalkthroughUpdated the GitHub Actions workflow configuration in the documentation build pipeline to explicitly specify checkout of the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/docs.yml:
- Line 27: Replace the hardcoded "ref: main" in the checkout step with an
event-aware expression so pull_request builds use the PR branch and
release/workflow_dispatch use main; update the checkout ref to use the pull
request head when github.event_name == 'pull_request' (e.g. use "${{
github.event.pull_request.head.ref }}" or a conditional like "${{
github.event_name == 'pull_request' && github.event.pull_request.head.ref ||
'main' }}" so the checkout action uses the triggering ref for PRs and main for
release/workflow_dispatch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bc18c241-e9bb-42e8-a72f-a8aee037707a
📒 Files selected for processing (1)
.github/workflows/docs.yml
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4 | ||
| with: | ||
| ref: main |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/docs.ymlRepository: driessamyn/kapper
Length of output: 2603
Use event-aware checkout ref to validate PR changes
Hardcoding ref: main on line 27 forces pull_request builds to use main branch code instead of the PR branch, preventing validation of PR changes to docs/, core/src/, or coroutines/src/. For release and workflow_dispatch events, main is the correct source; for pull_request, use the triggering ref.
Suggested patch
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
with:
- ref: main
+ ref: ${{ github.event_name == 'release' && 'refs/heads/main' || github.ref }}
fetch-depth: 0📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ref: main | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4 | |
| with: | |
| ref: ${{ github.event_name == 'release' && 'refs/heads/main' || github.ref }} | |
| fetch-depth: 0 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/docs.yml at line 27, Replace the hardcoded "ref: main" in
the checkout step with an event-aware expression so pull_request builds use the
PR branch and release/workflow_dispatch use main; update the checkout ref to use
the pull request head when github.event_name == 'pull_request' (e.g. use "${{
github.event.pull_request.head.ref }}" or a conditional like "${{
github.event_name == 'pull_request' && github.event.pull_request.head.ref ||
'main' }}" so the checkout action uses the triggering ref for PRs and main for
release/workflow_dispatch.
Unit Tests 62 files ±0 62 suites ±0 2m 59s ⏱️ ±0s Results for commit a45b3df. ± Comparison against base commit c62a51f. This pull request removes 39 and adds 39 tests. Note that renamed tests count towards both. |
Code Coverage
Updated for commit a45b3df |
|



Summary
mainfor the docs build, since release events use the tag ref which is rejected by thegithub-pagesenvironment branch protection rulesContext
The v2.0.0 docs deployment failed because the release event checked out the
2.0.0tag ref, which thegithub-pagesenvironment protection rules don't allow. Docs should always be built frommain.Test plan
Summary by CodeRabbit