> **Page index:** https://km.oslo.systems/llms.txt lists every page on this site, with a link to its Markdown version.

# Prepare infrastructure repository

Prepare an existing infrastructure repository for the new Terraform plan/apply GitHub Actions workflows.

## Before you begin

Familiarize yourself with [the key points from the risk assessment analysis (ROS)](<https://github.com/oslokommune/golden-path-docs-internal/blob/main/oppsummering-ros-nytt-cicd-oppsett.md>).

## Step 1: Protect your default branch

Your repository automatically inherits a set of branch rulesets from the GitHub organization when you add a specific custom property to it. These rulesets add a set of required guardrails to your repository. You **must** set up these rulesets to protect your default branch (typically `main`).

1. In your repository, go to **Settings \> Custom properties** and set `gp-repository-type` to `infra`.
2. After setting the custom property, verify that **Settings \> Rulesets** have rules inherited from the organization.

## Step 2: Remove overlapping rulesets

The organization-level rulesets from the previous step replace any repo-level rulesets that Utviklerflyt has set up for you - if any. If your repository has repo-level rulesets such as "Protect default branch" or "Require team approval", you can now remove them. [Contact Utviklerflyt](<https://km.oslo.systems/help/contact-us/index.md>) if you are unsure which to remove.

## Step 3: Review repository access

Go to **Settings \> Collaborators and teams** and ensure that only a limited number of users, such as your product team, have write access to your repository.

## Step 4: Disable overlapping workflows

Disable any existing GitHub Actions workflows that run Terraform plan or apply to avoid conflicts with the new workflows.

1. Go to **Actions** in the repository
2. Select the workflow to disable
3. Any old CI/CD workflows from Golden Path (ending with `- Terraform on changed dirs`) should be disabled if present.
4. Select the **three-dot menu** and choose **Disable workflow**

[Contact Utviklerflyt](<https://km.oslo.systems/help/contact-us/index.md>) if you are unsure which to disable.

## Next steps

[Add the plan workflow](<https://km.oslo.systems/terraform-automation/migrate-to-latest-workflows/add-plan-workflow/index.md>) and supporting configuration files.
