This repository is for deploying repositories to GitHub using Terraform and GitHub Actions.
- A GitHub Actions workflow is triggered (e.g., when a pull request is merged).
- The
set-matrix
action is executed to create a list of directories for Terraform execution. - The
setup-terraform
action is executed to set up Terraform. - The
terraform-plan
action is executed to create a Terraform plan. - The
terraform-apply
action is executed to apply the Terraform plan.
graph TD
A[actions checkout] --> B[AWS credential aws-credential]
B --> C[Generate GitHub App token]
C --> D[Terraform Plan]
D --> E[Start Deployment]
E --> F{push or workflow_dispatch}
F -- Yes --> G[Terraform Apply]
F -- No --> H[Skip]
G --> I[Finish Deployment]
H --> I
This workflow is used to import existing GitHub repositories into Terraform management.
- The
terraform-import
workflow allows you to import existing GitHub repositories and branch protection settings into the Terraform state. - It is executed manually (
workflow_dispatch
) by specifying the target module name and repository name.
graph TD
A[Select Import workflow in Actions tab] --> B[Enter module and repo then run]
B --> C[Checkout repository]
C --> D[Configure AWS credentials]
D --> E[Initialize Terraform]
E --> F[Import repository info to state]
F --> G[Done]
module
: Terraform module name (e.g.,local-workspace-provisioning
,terraform-aws
,boilerplate-saas
, etc.)repo
: GitHub repository name (e.g.,local-workspace-provisioning
,terraform-aws
,boilerplate-saas
, etc.)
- Go to the Actions tab in GitHub and select the
Terraform Import
workflow. - Click the
Run workflow
button, enter themodule
andrepo
values, and start the workflow.- Example:
module
=local-workspace-provisioning
,repo
=local-workspace-provisioning
- Example:
module
=terraform-aws
,repo
=terraform-aws
- Example:
- When the workflow completes, the specified repository information will be imported into the Terraform state.
- For
module
, specify the module name underterraform/src/repository/
. - For
repo
, specify the repository name on GitHub. - Make sure that
secrets.TERRAFORM_GITHUB_TOKEN
is set as required.