Repository navigation
chore(github/repository): limit the platform production environment to release tags - #1107
Merged
Merged
Conversation
…o release tags Signed-off-by: panicboat <panicboat@gmail.com>
…onment Signed-off-by: panicboat <panicboat@gmail.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Contributor
Plan Result (repository/master)
Change Result (Click me) # github_repository_environment.repository["platform/production"] will be created
+ resource "github_repository_environment" "repository" {
+ can_admins_bypass = false
+ environment = "production"
+ id = (known after apply)
+ prevent_self_review = false
+ repository = "platform"
+ repository_id = (known after apply)
+ deployment_branch_policy {
+ custom_branch_policies = true
+ protected_branches = false
}
}
# github_repository_environment_deployment_policy.repository["platform/production/*-v*"] will be created
+ resource "github_repository_environment_deployment_policy" "repository" {
+ environment = "production"
+ id = (known after apply)
+ policy_id = (known after apply)
+ repository = "platform"
+ repository_id = (known after apply)
+ tag_pattern = "*-v*"
}
Plan: 2 to add, 0 to change, 0 to destroy. |
Contributor
✅ Apply Succeeded (repository/master)Details (Click me)Oct 24 12:57:28.904 INF download and unarchive the package program=aqua version=2.64.0 env=linux/amd64 exe_name=terragrunt package_name=gruntwork-io/terragrunt package_version=v1.0.2 registry=standard
Initializing the backend...
Successfully configured the backend "s3"! OpenTofu will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 6.68"...
- Finding integrations/github versions matching "~> 6.13"...
- Installing integrations/github v6.13.0 to the shared cache directory...
- Installing hashicorp/aws v6.70.0 to the shared cache directory...
- Installed integrations/github v6.13.0 (signed, key ID 38027F80D7FD5FB2)
- Using integrations/github v6.13.0 from the shared cache directory
- Installed hashicorp/aws v6.70.0 (signed, key ID 0C0AF313E5FD9F80)
- Using hashicorp/aws v6.70.0 from the shared cache directory
Providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://opentofu.org/docs/cli/plugins/signing/
OpenTofu has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that OpenTofu can guarantee to make the same selections by default when
you run "tofu init" in the future.
OpenTofu has been successfully initialized!
You may now begin working with OpenTofu. Try running "tofu plan" to see
any changes that are required for your infrastructure. All OpenTofu commands
should now work.
If you ever set or change modules or backend configuration for OpenTofu,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
github_repository.repository["monorepo"]: Refreshing state... [id=monorepo]
github_repository.repository["deploy-actions"]: Refreshing state... [id=deploy-actions]
github_repository.repository["platform"]: Refreshing state... [id=platform]
github_repository.repository["dotfiles"]: Refreshing state... [id=dotfiles]
github_repository.repository["ansible"]: Refreshing state... [id=ansible]
github_workflow_repository_permissions.repository["platform"]: Refreshing state... [id=platform]
github_workflow_repository_permissions.repository["monorepo"]: Refreshing state... [id=monorepo]
github_repository_vulnerability_alerts.repository["platform"]: Refreshing state... [id=994278495]
github_repository_vulnerability_alerts.repository["deploy-actions"]: Refreshing state... [id=1014666976]
github_repository_vulnerability_alerts.repository["monorepo"]: Refreshing state... [id=807388271]
github_repository_vulnerability_alerts.repository["ansible"]: Refreshing state... [id=880089351]
github_repository_vulnerability_alerts.repository["dotfiles"]: Refreshing state... [id=880093624]
OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
OpenTofu will perform the following actions:
# github_repository_environment.repository["platform/production"] will be created
+ resource "github_repository_environment" "repository" {
+ can_admins_bypass = false
+ environment = "production"
+ id = (known after apply)
+ prevent_self_review = false
+ repository = "platform"
+ repository_id = (known after apply)
+ deployment_branch_policy {
+ custom_branch_policies = true
+ protected_branches = false
}
}
# github_repository_environment_deployment_policy.repository["platform/production/*-v*"] will be created
+ resource "github_repository_environment_deployment_policy" "repository" {
+ environment = "production"
+ id = (known after apply)
+ policy_id = (known after apply)
+ repository = "platform"
+ repository_id = (known after apply)
+ tag_pattern = "*-v*"
}
Plan: 2 to add, 0 to change, 0 to destroy.
github_repository_environment.repository["platform/production"]: Creating...
github_repository_environment.repository["platform/production"]: Creation complete after 2s [id=platform:production]
github_repository_environment_deployment_policy.repository["platform/production/*-v*"]: Creating...
github_repository_environment_deployment_policy.repository["platform/production/*-v*"]: Creation complete after 1s [id=platform:production:64198899]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
Outputs:
repository_full_names = {
"ansible" = "panicboat/ansible"
"deploy-actions" = "panicboat/deploy-actions"
"dotfiles" = "panicboat/dotfiles"
"monorepo" = "panicboat/monorepo"
"platform" = "panicboat/platform"
}
repository_html_urls = {
"ansible" = "https://github.com/panicboat/ansible"
"deploy-actions" = "https://github.com/panicboat/deploy-actions"
"dotfiles" = "https://github.com/panicboat/dotfiles"
"monorepo" = "https://github.com/panicboat/monorepo"
"platform" = "https://github.com/panicboat/platform"
}
repository_http_clone_urls = {
"ansible" = "https://github.com/panicboat/ansible.git"
"deploy-actions" = "https://github.com/panicboat/deploy-actions.git"
"dotfiles" = "https://github.com/panicboat/dotfiles.git"
"monorepo" = "https://github.com/panicboat/monorepo.git"
"platform" = "https://github.com/panicboat/platform.git"
}
repository_ids = {
"ansible" = 880089351
"deploy-actions" = 1014666976
"dotfiles" = 880093624
"monorepo" = 807388271
"platform" = 994278495
}
repository_node_ids = {
"ansible" = "R_kgDONHUZBw"
"deploy-actions" = "R_kgDOPHqW4A"
"dotfiles" = "R_kgDONHUpuA"
"monorepo" = "R_kgDOMB_Ebw"
"platform" = "R_kgDOO0N8Xw"
}
repository_ssh_clone_urls = {
"ansible" = "git@github.com:panicboat/ansible.git"
"deploy-actions" = "git@github.com:panicboat/deploy-actions.git"
"dotfiles" = "git@github.com:panicboat/dotfiles.git"
"monorepo" = "git@github.com:panicboat/monorepo.git"
"platform" = "git@github.com:panicboat/platform.git"
}
|
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
production の apply role は OIDC subject
repo:panicboat/platform:environment:productionを許可している。job が
environment: productionを宣言すれば、どの branch から起動した workflow でもこの token を得られる。GitHub environment
productionに deployment policy を付け、release tag(<service>-vX.Y.Z)以外の ref で動く job を GitHub に止めさせる。What
github/repositoryの module で、repository ごとに GitHub environment と tag pattern の deployment policy を宣言できるようにする。productionに tag pattern*-v*を設定する。custom_branch_policies = trueにして、policy に一致しない ref からの deployment を拒否させる。can_admins_bypass = falseにして、admin が起動した job も同じ扱いにする。*-v*からの deployment だけを受け付けることを書く。Merge 順と影響
productionを自動作成していても、そのまま管理に取り込む。environment: productionを宣言する job はないので、先に merge しても止まる job はない。--ref <tag>で起動する必要がある(ci: gate production terragrunt applies behind service releases #1105 の README に記載済み)。Test plan
tofu test(github/repository/modules)が 2 passedcan_admins_bypass・custom_branch_policiesなどを壊すと、テストが失敗するtofu fmt -check -recursive github/repositoryとtofu validateが成功github/repositoryの plan に、environment と policy の追加だけが出るgh api repos/panicboat/platform/environments/productionで policy が tag*-v*になっているenvironment: productionの job を起動すると、GitHub に拒否される🤖 Generated with Claude Code
https://claude.ai/code/session_01BZfNTtmPjmrDmh1MAMtiFS