Skip to content

ci: auto-formatのdetached HEAD pushを修正 (#36) - #39

Merged
MRyutaro merged 1 commit into
mainfrom
fix/issue-36-autoformat-detached-head
Jun 14, 2026
Merged

MRyutaro merged 1 commit into
mainfrom
fix/issue-36-autoformat-detached-head

Conversation

@MRyutaro

Copy link
Copy Markdown
Owner

概要

.github/workflows/format-python-code.yml(auto-format)が pull_request イベントで必ず失敗する問題(#36)を修正する。

原因

pull_request イベントでは actions/checkout がマージ commit を detached HEAD でチェックアウトするため、ワークフロー末尾の git push(暗黙に現在ブランチを push)が以下で失敗していた:

fatal: You are not currently on a branch.
##[error]Process completed with exit code 128.

ファイル内容やフォーマット差分とは無関係な構造的問題で、どの PR でも再現する(main への push イベント時のみ成功)。

修正内容

Issue の修正案 2 を採用。actions/checkout に ref: ${{ github.head_ref }} を指定し、PR の元ブランチをブランチ状態でチェックアウトしてから push する。

  • pull_request 時: github.head_ref = PR の元ブランチ → ブランチ状態で checkout → git push 成功
  • push(main)時: github.head_ref は空 → 既定の挙動になり影響なし

自動整形運用を維持する方針(Q2)に沿った変更。

関連

🤖 Generated with Claude Code

pull_requestイベントではactions/checkoutがマージcommitをdetached HEADで
チェックアウトするため、ワークフロー末尾のgit pushが
"You are not currently on a branch"で必ず失敗していた。

checkoutにref: ${{ github.head_ref }}を指定し、PRの元ブランチを
ブランチ状態でチェックアウトしてからpushするよう修正。
push(main)イベント時はgithub.head_refが空のため既定の挙動になり影響しない。

Closes #36

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MRyutaro
MRyutaro merged commit db12d73 into main Jun 14, 2026
1 check passed
@MRyutaro
MRyutaro deleted the fix/issue-36-autoformat-detached-head branch June 14, 2026 14:15
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.

auto-formatワークフローがPull Requestで必ず失敗する(detached HEADでgit pushできない)

1 participant