Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github_branch needs to not fail if branch doesn't exist #747

Closed
threeseed opened this issue Mar 31, 2021 · 0 comments · Fixed by #806
Closed

github_branch needs to not fail if branch doesn't exist #747

threeseed opened this issue Mar 31, 2021 · 0 comments · Fixed by #806
Labels
Good first issue Good for newcomers r/branch Type: Feature New feature or request

Comments

@threeseed
Copy link
Contributor

Affected Resource(s)

  • github_branch

For a new repository (or one in which the branch doesn't exist) the following will fail the entire plan/apply. It would be nice if etag/ref/sha were null so that we could use that to conditionally create other resources.

In my case I want to set the develop branch to the default IF the branch exists.

Terraform Configuration Files

data "github_branch" "main" {
  repository                = github_repository.repository.name
  branch                    = "develop"
}

Error Output

GET https://api.github.com/repos/<org>/<repo>/git/ref/heads/main: 404 Not Found []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Good for newcomers r/branch Type: Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants