Skip to content

ci: import the ruleset by the ID it was created with - #9

Merged
lens0021 merged 1 commit into
mainfrom
claude/github-actions-workflows-bbht4a
Aug 15, 2026
Merged

ci: import the ruleset by the ID it was created with#9
lens0021 merged 1 commit into
mainfrom
claude/github-actions-workflows-bbht4a

Conversation

@lens0021

Copy link
Copy Markdown
Contributor

The ruleset exists now (20882589), so the import can point at it. Until it did, the ID could not
be written down, and every run planned to create a ruleset that was already there — which is what
the open drift issue (#4) has been reporting.

State is not kept between runs and a ruleset can be imported by numeric ID and no other way, so
the ID lives in the configuration. The ruleset_id variable that guarded the import is gone with
it: it existed only to keep the plan working while no ruleset existed, and a plain import block is
what the other repository using this setup does.

Verifying

The plan this PR posts is the check. It should now show the ruleset being imported rather than
created, and no changes to it — if the ID were wrong, the plan would fail on the import instead.

tofu fmt -check and tofu validate pass locally against the pinned provider.


Generated by Claude Code

Every run planned to create a ruleset that already existed, which is what the
open drift issue has been reporting. State is not kept between runs and a
ruleset can be imported by numeric ID and no other way, so the ID has to be
written down in the configuration -- 20882589, from the apply that created it.

The variable that guarded the import is gone with it. It existed only to keep
the plan working while no ruleset existed, and there is one now; a plain
import block is what the other repository using this setup does too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6rDhYwHnJwtMQn8nPA1de
@github-actions

Copy link
Copy Markdown
Contributor

OpenTofu Plan

github_repository.this: Preparing import... [id=setup-mago]
github_repository.this: Refreshing state... [id=setup-mago]
github_repository_ruleset.default: Preparing import... [id=setup-mago:20882589]
github_repository_ruleset.default: Refreshing state... [id=20882589]

OpenTofu used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place (current -> planned)

OpenTofu will perform the following actions:

  # github_repository.this will be updated in-place
  # (imported from "setup-mago")
  ~ resource "github_repository" "this" {
        allow_auto_merge                        = true
        allow_forking                           = true
        allow_merge_commit                      = false
        allow_rebase_merge                      = false
        allow_squash_merge                      = true
        allow_update_branch                     = true
        archived                                = false
        auto_init                               = false
        default_branch                          = "main"
        delete_branch_on_merge                  = true
        description                             = "Install the mago PHP toolchain in GitHub Actions."
        etag                                    = "W/\"d3d8b255d96708dc11e2f3f165b770837e4176e9ed9f63552a1711cb05a5cde1\""
        fork                                    = "false"
        full_name                               = "chaotic-ground/setup-mago"
        git_clone_url                           = "git://github.com/chaotic-ground/setup-mago.git"
        has_discussions                         = false
        has_downloads                           = false
        has_issues                              = true
        has_projects                            = false
        has_wiki                                = false
        html_url                                = "https://github.com/chaotic-ground/setup-mago"
        http_clone_url                          = "https://github.com/chaotic-ground/setup-mago.git"
        id                                      = "setup-mago"
      + ignore_vulnerability_alerts_during_read = false
        is_template                             = false
      ~ merge_commit_message                    = "PR_TITLE" -> "PR_BODY"
      ~ merge_commit_title                      = "MERGE_MESSAGE" -> "PR_TITLE"
        name                                    = "setup-mago"
        node_id                                 = "R_kgDOT46v6Q"
        primary_language                        = "Shell"
        private                                 = false
        repo_id                                 = 1334751209
        squash_merge_commit_message             = "PR_BODY"
        squash_merge_commit_title               = "PR_TITLE"
        ssh_clone_url                           = "git@github.com:chaotic-ground/setup-mago.git"
        svn_url                                 = "https://github.com/chaotic-ground/setup-mago"
        topics                                  = [
            "github-actions",
            "mago",
            "php",
            "static-analysis",
        ]
        visibility                              = "public"
        web_commit_signoff_required             = false
    }

  # github_repository_ruleset.default will be updated in-place
  # (imported from "setup-mago:20882589")
  ~ resource "github_repository_ruleset" "default" {
        enforcement = "active"
        etag        = "W/\"4db04ad05d209d8aae7e52b54a51487bbba7ef8e421df1916f00a917147183b8\""
        id          = "20882589"
        name        = "default"
        node_id     = "RRS_lACqUmVwb3NpdG9yec5Pjq_pzgE-pJ0"
        repository  = "setup-mago"
        ruleset_id  = 20882589
        target      = "branch"

        conditions {
            ref_name {
                exclude = []
                include = [
                    "~DEFAULT_BRANCH",
                ]
            }
        }

      ~ rules {
            creation                      = false
            deletion                      = true
            non_fast_forward              = true
            required_linear_history       = false
            required_signatures           = false
            update                        = false
            update_allows_fetch_and_merge = false

            pull_request {
                allowed_merge_methods             = [
                    "merge",
                    "squash",
                    "rebase",
                ]
                dismiss_stale_reviews_on_push     = false
                require_code_owner_review         = false
                require_last_push_approval        = false
                required_approving_review_count   = 0
                required_review_thread_resolution = false
            }

          ~ required_status_checks {
                do_not_enforce_on_create             = false
                strict_required_status_checks_policy = false

                required_check {
                    context        = "checksum"
                    integration_id = 15368
                }
                required_check {
                    context        = "install (macos-latest)"
                    integration_id = 15368
                }
                required_check {
                    context        = "install (ubuntu-24.04-arm)"
                    integration_id = 15368
                }
                required_check {
                    context        = "install (ubuntu-latest)"
                    integration_id = 15368
                }
                required_check {
                    context        = "latest"
                    integration_id = 15368
                }
                required_check {
                    context        = "rumdl"
                    integration_id = 15368
                }
                required_check {
                    context        = "semantic-pull-request"
                    integration_id = 15368
                }
                required_check {
                    context        = "typos"
                    integration_id = 15368
                }
                required_check {
                    context        = "yamllint"
                    integration_id = 15368
                }
                required_check {
                    context        = "zizmor"
                    integration_id = 15368
                }
              + required_check {
                  + context        = "detect"
                  + integration_id = 15368
                }
              + required_check {
                  + context        = "install (windows-latest)"
                  + integration_id = 15368
                }
              + required_check {
                  + context        = "shellcheck"
                  + integration_id = 15368
                }
              + required_check {
                  + context        = "version (macos-latest)"
                  + integration_id = 15368
                }
              + required_check {
                  + context        = "version (ubuntu-latest)"
                  + integration_id = 15368
                }
              + required_check {
                  + context        = "version (windows-latest)"
                  + integration_id = 15368
                }
            }
        }
    }

Plan: 2 to import, 0 to add, 2 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so OpenTofu can't
guarantee to take exactly these actions if you run "tofu apply" now.

View run

@lens0021
lens0021 marked this pull request as ready for review August 15, 2026 06:37
@lens0021
lens0021 merged commit 6a11be6 into main Aug 15, 2026
18 checks passed
@lens0021
lens0021 deleted the claude/github-actions-workflows-bbht4a branch August 15, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants