You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: github_repository: Pages is enabled before gh-pages branch is created – API returns 422 #2671
A single terraform apply should
1. create the repository,
2. create the gh-pages branch,
3. enable GitHub Pages that serves from that branch, and
4. exit successfully (plan: 2 to add, 0 to change, 0 to destroy).
Actual Behavior
During the same apply the provider sends the POST /repos/{owner}/{repo}/pages request before the gh-pages branch exists, so GitHub responds
422 Validation Failed – The gh-pages branch must exist before GitHub Pages can be built.
Terraform Version
Terraform v1.5.0
on linux_amd64
provider registry.terraform.io/integrations/github v6.5.2
Affected Resource(s)
• github_repository
• github_branch
Terraform Configuration Files
The smallest reproducible case
terraform {
required_providers {
github={
source ="integrations/github"
version ="~> 6.5"
}
}
}
provider"github" {
owner=var.github_owner# e.g. "my-org"token=var.github_token# PAT with repo + pages:write
}
# --- repository ------------------------------------------------------resource"github_repository""pages_site" {
name="pages-test-single-apply"visibility="public"auto_init=true# seeds the default branch (main)pages { # <-- fails because branch not yet theresource {
branch="gh-pages"path="/"
}
}
delete_branch_on_merge=true
}
# --- branch ----------------------------------------------------------resource"github_branch""gh_pages" {
repository=github_repository.pages_site.namebranch="gh-pages"source_branch=github_repository.pages_site.default_branch
}
Steps to Reproduce
Steps to Reproduce
1. terraform init
2. terraform apply → observe the 422 error above.
Debug Output
github_repository.pages_site: Creating...
│ Error: POST https://api.github.com/repos/<org>/pages-test-single-apply/pages: 422 The gh-pages branch must exist before GitHub Pages can be built. []
│
│ with github_repository.pages_site,
│ on main.tf line 18, in resource "github_repository""pages_site":
│ 18: resource "github_repository""pages_site" {
Activity