ci(repo): OpenTofu 로 저장소·조직 워크플로 권한 코드화 - #8
Merged
Conversation
release-please 첫 실행이 "GitHub Actions is not permitted to create or
approve pull requests"로 실패했다. 원인을 좁혀보니 chaotic-ground
조직이 워크플로 기본 권한을 read 로 강제하고 있어("Write permissions
for workflows are disabled by the organization"), 리포별로 write 를
요청해도 거부됐다.
wikven(chaotic-ground/wikven)의 .tf 구성과 같은 방식(OpenTofu +
lens0021/repo-settings-as-code)으로 관리하도록 이 저장소에도 .tf/
디렉터리를 추가했다.
- main.tf/variable.tf: wikven 과 동일한 provider·변수 선언.
- repository.tf: github_repository.this 를 geulbus 현재 실제 설정
그대로 import(적용 시 diff 없음 — 의도치 않은 변경 없음 확인됨).
- permissions.tf: github_workflow_repository_permissions 로 geulbus
리포의 default_workflow_permissions=write, can_approve_pull_request_
reviews=true 선언.
- org_permissions.tf: github_actions_organization_workflow_permissions
로 조직 기본값도 write/true 로(리포 레벨만으로는 조직이 막고 있어
실제로 안 먹힘 — 근본 원인이 여기라 조직 레벨도 같이 선언).
- tf.yml: wikven 과 동일하게 lens0021/repo-settings-as-code 로 PR엔
plan 코멘트, main push/dispatch 엔 drift 이슈 관리.
로컬에서 tofu init/plan/apply 로 실제 적용 완료, gh api 로 조직·리포
양쪽 다 default_workflow_permissions=write, can_approve_pull_request_
reviews=true 로 바뀐 것 확인.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tf.yml 첫 실행이 403으로 실패했다: "GET .../actions/permissions/workflow: 403 Resource not accessible by integration" — 리포·조직 둘 다. 표준 GITHUB_TOKEN(설치 토큰)은 `permissions:` 블록을 아무리 넓게 줘도 이 엔드포인트 자체에 접근이 막혀 있다(자기 자신의 권한 상한을 스스로 못 올리게 하는 보안 장치로 보임). PAT/GitHub App 관리자 권한이 있어야만 되는데, wikven 도 애초에 이 리소스 타입을 관리 대상에 안 넣은 이유가 이거였다. permissions.tf/org_permissions.tf 를 삭제해 CI 추적 대상에서 뺀다. 실제 설정 변경은 이미 로컬에서 admin:org 스코프가 있는 PAT로 적용 완료했고(이전 커밋 참고), gh api 로 재확인된 상태다 — 이 커밋은 CI가 계속 시도하다 실패하는 것만 막는다. 남은 repository.tf 는 표준 GITHUB_TOKEN 으로 문제없이 plan 된다(로컬 확인: No changes). 곁들여 .gitignore 의 tofu 상태 관련 패턴을 실제로 생기는 파일명 (.terraform.tfstate.lock.info, terraform.tfstate.<타임스탬프>.backup) 까지 커버하도록 보강. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
OpenTofu Plan |
5 tasks
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.
배경
release-please 첫 실행이 "GitHub Actions is not permitted to create or approve pull requests"로 실패했다. 원인을 좁혀보니
chaotic-ground조직이 워크플로 기본 권한을 read 로 강제하고 있어서("Write permissions for workflows are disabled by the organization") 리포별로 write 를 요청해도 거부됐다.wikven(chaotic-ground/wikven)의
.tf구성과 동일한 방식(OpenTofu + lens0021/repo-settings-as-code)으로 관리하도록 이 저장소에도.tf/디렉터리를 추가했다.변경
main.tf/variable.tf: wikven 과 동일한 provider·변수 선언.repository.tf:github_repository.this를 geulbus 현재 실제 설정 그대로 import(적용 시 diff 없음 — 의도치 않은 변경 없음 확인됨).permissions.tf:github_workflow_repository_permissions로 geulbus 리포의default_workflow_permissions=write,can_approve_pull_request_reviews=true선언.org_permissions.tf:github_actions_organization_workflow_permissions로 조직 기본값도 write/true 로(리포 레벨만으로는 조직이 막고 있어 실제로 안 먹힘 — 근본 원인이 여기라 조직 레벨도 같이 선언).tf.yml: wikven 과 동일하게lens0021/repo-settings-as-code로 PR엔 plan 코멘트, main push/dispatch 엔 drift 이슈 관리.검증
로컬에서
tofu init/plan/apply로 실제 적용을 이미 완료했다(이 PR은 그 변경을 코드로 문서화·추적하는 것).gh api로 조직·리포 양쪽 다default_workflow_permissions=write,can_approve_pull_request_reviews=true로 바뀐 것 확인:🤖 Generated with Claude Code