From 862655c0c65c87e6a6b56ef11b316f85dd96694a Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Wed, 27 Dec 2023 08:53:27 +0100 Subject: [PATCH] Dependabot: add github action to fix modules on PRs and add test to configuration --- .github/dependabot.yml | 34 +++++++++++++++---- .github/workflows/pr-dependabot.yaml | 49 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pr-dependabot.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1e4197a160..e94686cffa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,27 +11,49 @@ updates: prefix: ":seedling:" labels: - "ok-to-test" - -# Go +# Main Go module - package-ecosystem: "gomod" directory: "/" schedule: interval: "weekly" day: "monday" - ## group all dependencies with a k8s.io prefix into a single PR where possible + ## group all dependencies with a k8s.io prefix into a single PR. groups: kubernetes: patterns: [ "k8s.io/*" ] ignore: - # Ignore k8s and its transitives modules as they are upgraded manually - # together with controller-runtime. + # Ignore controller-runtime as its upgraded manually. + - dependency-name: "sigs.k8s.io/controller-runtime" + update-types: [ "version-update:semver-major", "version-update:semver-minor" ] + # Ignore k8s and its transitives modules as they are upgraded manually together with controller-runtime. - dependency-name: "k8s.io/*" update-types: [ "version-update:semver-major", "version-update:semver-minor" ] + - dependency-name: "sigs.k8s.io/cluster-api/test" + update-types: [ "version-update:semver-major", "version-update:semver-minor" ] + commit-message: + prefix: ":seedling:" + labels: + - "ok-to-test" + +# Test Go module +- package-ecosystem: "gomod" + directory: "/test" + schedule: + interval: "weekly" + day: "tuesday" + ## group all dependencies with a k8s.io prefix into a single PR. + groups: + kubernetes: + patterns: [ "k8s.io/*" ] + ignore: # Ignore controller-runtime as its upgraded manually. - dependency-name: "sigs.k8s.io/controller-runtime" update-types: [ "version-update:semver-major", "version-update:semver-minor" ] + # Ignore k8s and its transitives modules as they are upgraded manually together with controller-runtime. + - dependency-name: "k8s.io/*" + update-types: [ "version-update:semver-major", "version-update:semver-minor" ] - dependency-name: "sigs.k8s.io/cluster-api/test" - update-types: ["version-update:semver-major", "version-update:semver-minor"] + update-types: [ "version-update:semver-major", "version-update:semver-minor" ] commit-message: prefix: ":seedling:" labels: diff --git a/.github/workflows/pr-dependabot.yaml b/.github/workflows/pr-dependabot.yaml new file mode 100644 index 0000000000..002dfca8f2 --- /dev/null +++ b/.github/workflows/pr-dependabot.yaml @@ -0,0 +1,49 @@ +name: PR dependabot code generation and go modules fix + +# This action runs on other PRs opened by dependabot. It updates modules and generated code on PRs opened by dependabot. +on: + pull_request: + branches: + - dependabot/** + push: + branches: + - dependabot/** + workflow_dispatch: + +permissions: + contents: write # Allow to update the PR. + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1 + - name: Calculate go version + id: vars + run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT + - name: Set up Go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v5.0.0 + with: + go-version: ${{ steps.vars.outputs.go_version }} + - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # tag=v3.3.2 + name: Restore go cache + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Update all modules + run: make generate-modules + - name: Update generated code + run: make generate + - uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 # tag=v9.1.3 + name: Commit changes + with: + author_name: dependabot[bot] + author_email: 49699333+dependabot[bot]@users.noreply.github.com + default_author: github_actor + message: 'Update generated code'