From a2b111dac5b56110d16a743664a023e24bf7a3cb Mon Sep 17 00:00:00 2001 From: Nuru Date: Thu, 13 Apr 2023 12:08:19 -0700 Subject: [PATCH] Support release branches and default branch named "main" (#346) --- templates/terraform/.github/mergify.yml | 17 ++++++++++++++--- templates/terraform/.github/renovate.json | 1 + .../.github/workflows/auto-context.yml | 12 +++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/templates/terraform/.github/mergify.yml b/templates/terraform/.github/mergify.yml index ef15545e..148d85c0 100644 --- a/templates/terraform/.github/mergify.yml +++ b/templates/terraform/.github/mergify.yml @@ -4,13 +4,17 @@ pull_request_rules: - name: "approve automated PRs that have passed checks" conditions: - "author~=^(cloudpossebot|renovate\\[bot\\])$" - - "base=master" - "-closed" - "head~=^(auto-update|renovate)/.*" - "check-success=test/bats" - "check-success=test/readme" - "check-success=test/terratest" - "check-success=validate-codeowners" + - or: + - "base=master" + - "base=main" + - "base~=^release/v\\d{1,2}$" + actions: review: type: "APPROVE" @@ -20,7 +24,6 @@ pull_request_rules: - name: "merge automated PRs when approved and tests pass" conditions: - "author~=^(cloudpossebot|renovate\\[bot\\])$" - - "base=master" - "-closed" - "head~=^(auto-update|renovate)/.*" - "check-success=test/bats" @@ -30,6 +33,11 @@ pull_request_rules: - "#approved-reviews-by>=1" - "#changes-requested-reviews-by=0" - "#commented-reviews-by=0" + - or: + - "base=master" + - "base=main" + - "base~=^release/v\\d{1,2}$" + actions: merge: method: "squash" @@ -50,7 +58,10 @@ pull_request_rules: - name: "remove outdated reviews" conditions: - - "base=master" + - or: + - "base=master" + - "base=main" + - "base~=^release/v\\d{1,2}$" actions: dismiss_reviews: changes_requested: true diff --git a/templates/terraform/.github/renovate.json b/templates/terraform/.github/renovate.json index a7802980..b61ed24f 100644 --- a/templates/terraform/.github/renovate.json +++ b/templates/terraform/.github/renovate.json @@ -3,6 +3,7 @@ "config:base", ":preserveSemverRanges" ], + "baseBranches": ["main", "master", "/^release\\/v\\d{1,2}$/"], "labels": ["auto-update"], "dependencyDashboardAutoclose": true, "enabledManagers": ["terraform"], diff --git a/templates/terraform/.github/workflows/auto-context.yml b/templates/terraform/.github/workflows/auto-context.yml index 831e7faa..e439b602 100644 --- a/templates/terraform/.github/workflows/auto-context.yml +++ b/templates/terraform/.github/workflows/auto-context.yml @@ -11,6 +11,16 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Find default branch name + id: defaultBranch + shell: bash + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + run: | + default_branch=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name) + echo "defaultBranch=${default_branch}" >> "$GITHUB_OUTPUT" + printf "defaultBranchRef.name=%s\n" "${default_branch}" + - name: Update context.tf shell: bash id: update @@ -50,7 +60,7 @@ jobs: To support all the features of the `context` interface. branch: auto-update/context.tf - base: master + base: ${{ steps.defaultBranch.outputs.defaultBranch }} delete-branch: true labels: | auto-update