fix(ci): changepacks 가 base branch 로컬 ref 를 찾지 못해 실패하는 문제 - #204
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
changepacks잡이 실패합니다.main 에서 이미 실패하고 있던 버그입니다. #171 이나 #167 과 무관합니다.
#167 이
go-test를changepacks의needs에 넣은 뒤로go-test가 계속 깨져 있어서, 그 사이 PR 들에서는changepacks가 아예 실행되지 못해 드러나지 않았습니다. #202 · #203 으로go-test가 복구되자 다시 보이기 시작했습니다.원인
actions/checkout이 실제로 실행하는 명령은 이렇습니다.fetch-depth: 0이라 이력은 전부 받지만, 브랜치는refs/remotes/origin/*로만 들어옵니다.ref:에 SHA 를 주므로 detached HEAD 가 됩니다. 따라서refs/heads/main은 만들어지지 않습니다.changepacks/action은 base branch 를 로컬 ref (refs/heads/<name>) 에서 찾습니다.ref:에 SHA 를 주는 것은 fork PR 의 코드를 점검하기 위해 필요하므로 그대로 두고, 로컬 ref 만 세워 줍니다.수정
checkout 다음에 한 스텝을 추가합니다.
pull_request_target이면github.event.pull_request.base.ref,push면github.ref_name— 둘 다main입니다.fetch-depth: 0으로 전부 받아둔 뒤라 추가 네트워크 비용이 없습니다.env로 넘겨 스크립트에 식이 직접 전개되지 않게 했습니다.git branch --force가 체크아웃된 브랜치와 충돌하지 않습니다.