# 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.
It is **required** to set up these to protect your default branch (typically `main`).

1. In your repository, go to **Settings > Custom properties** and set `gp-repository-type` to `infra`.
1. 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](../../help/contact-us.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
1. Select the workflow to disable
   - Any old CI/CD workflows from Golden Path (ending with `- Terraform on changed dirs`) should be disabled if present.
1. Select the **three-dot menu** and choose **Disable workflow**

[Contact Utviklerflyt](../../help/contact-us.md) if you are unsure which to disable.

## Next steps

[Add the plan workflow](add-plan-workflow.md) and supporting configuration files.
