Skip to content

Commit

Permalink
Import repo action (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Sep 2, 2024
1 parent 398b1a7 commit 4022113
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,10 @@ repositories = {
}
```

2. Import the repository into the terraform state by
running `terraform import -var-file=production/org.tfvars -var-file=production/repositories.tfvars -var github_token=... 'github_repository.this["repo-name"]' repo-name`
3. Run `terraform plan -var-file=production/org.tfvars -var-file=production/repositories.tfvars -var github_token=...`
to see the changes that will be made.

4. Create a pull-request to `main` branch. This will trigger terraform to plan the changes in the organization to be
2. Create a pull-request to `main` branch. This will trigger terraform to plan the changes in the organization to be
executed.
Review the changes and make sure they align with the request.
5. Merge the pull request. This will trigger terraform to apply the changes in the organization.
3. Merge the pull request. This will trigger terraform to apply the changes in the organization.

The expected changes:

Expand Down
15 changes: 12 additions & 3 deletions terraform/production/repositories.tfvars
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Organization repositories
repositories = {
# Keep the following repositories in alphabetical order

".github" = {
description = "A Special Repository."
Expand Down Expand Up @@ -54,8 +53,18 @@ repositories = {
}

"django-tasks-scheduler" = {
description = "Schedule async tasks using redis pub/sub."
homepage_url = "https://django-tasks-scheduler.readthedocs.io/"
description = "Schedule async tasks using redis pub/sub."
homepage_url = "https://django-tasks-scheduler.readthedocs.io/"
allow_merge_commit = true
admins = [
"cunla",
]
committers = []
members = []
}

"playground2" = {
description = "Tests"

admins = [
"cunla",
Expand Down
8 changes: 8 additions & 0 deletions terraform/resources-repos.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Github Repository Resource
# https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository

# Try to import the repository if it already exists
import {
for_each = var.repositories

id = each.key
to = github_repository.this[each.key]
}

resource "github_repository" "this" {
for_each = var.repositories

Expand Down

0 comments on commit 4022113

Please sign in to comment.