Skip to content

Commit

Permalink
Create new repositories using a template. (#499)
Browse files Browse the repository at this point in the history
Setting the default branch breaks on empty repositories. This change
ensures that new repositories are not created empty by setting a
repository template which, ironically, contains an empty commit on
Bloom's default configuration branch.

Because all repositories created to-date do not use this template and
future repositories created via import will also not use the template,
we should ignore this state once the repository is created.
  • Loading branch information
nuclearsandwich committed Apr 21, 2024
1 parent 6f58011 commit f7ebb05
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 00-repositories.tf
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ resource "github_repository" "repositories" {
archived = contains(local._archived_repositories, each.value)
visibility = "public"
has_projects = false

template {
owner = "ros2-gbp"
repository = "release-repository-template"
include_all_branches = true
}

lifecycle {
# Plans that destroy repository releases will delete the repository on
# GitHub and that shouldn't be done in the normal course of operation.
Expand All @@ -225,6 +232,7 @@ resource "github_repository" "repositories" {
has_issues,
has_wiki,
homepage_url,
template,
vulnerability_alerts
]
}
Expand Down
22 changes: 22 additions & 0 deletions 00-ros2_gbp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ resource "github_repository" "dotgithub" {
}
}

resource "github_repository" "release-repository-template" {
name = "release-repository-template"
visibility = "public"
is_template = true
has_projects = false
lifecycle {
# Plans that destroy repository releases will delete the repository on
# GitHub and that shouldn't be done in the normal course of operation.
prevent_destroy = true
# Ignore fields that are not set or managed by this terraform project
# to prevent unecessary drift.
ignore_changes = [
allow_merge_commit,
description,
has_downloads,
has_issues,
has_wiki,
vulnerability_alerts
]
}
}

resource "github_team" "docs_team" {
name = "ros2-gbp-docs"
description = "ros2-gbp documentation contributors"
Expand Down

0 comments on commit f7ebb05

Please sign in to comment.