From 29a515d875d96ce955c412c31ddb8601c64f2ee4 Mon Sep 17 00:00:00 2001 From: Jakob Jensen Date: Fri, 27 Feb 2026 21:49:03 +0100 Subject: [PATCH] feat: enable automatic update for golang version --- .github/workflows/dependabot.yaml | 2 +- .github/workflows/tests.yaml | 9 ++--- .github/workflows/upgrade-go.yaml | 62 +++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/upgrade-go.yaml diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml index cf6fb17..950955c 100644 --- a/.github/workflows/dependabot.yaml +++ b/.github/workflows/dependabot.yaml @@ -1,4 +1,4 @@ -name: Dependabot Auto Release +name: Auto Release on: push: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7dc3f13..7a1f7fd 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -90,12 +90,9 @@ jobs: private-key: ${{ secrets.APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --squash "$PR_URL" - if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}} + - name: Enable auto-merge for bot PRs + run: gh pr merge --admin --squash "$PR_URL" + if: (github.actor == 'dependabot[bot]' || github.actor == 'codereaper-automation[bot]') && github.event_name == 'pull_request' env: PR_URL: ${{ github.event.pull_request.html_url }} GH_TOKEN: ${{ steps.app-token.outputs.token }} - - - name: All clear - run: exit 0 diff --git a/.github/workflows/upgrade-go.yaml b/.github/workflows/upgrade-go.yaml new file mode 100644 index 0000000..a66e349 --- /dev/null +++ b/.github/workflows/upgrade-go.yaml @@ -0,0 +1,62 @@ +name: Upgrade Go Version + +on: + workflow_dispatch: + schedule: + - cron: "0 8 * * 1" + +jobs: + upgrade-go: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v6 + + - name: Create token + id: app-token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + + - name: Check for Go updates + id: check + run: | + CURRENT=$(grep "^go " go.mod | awk '{print $2}') + LATEST=$(go list -m -f '{{.Version}}' go@latest) + { + echo "latest=$LATEST" + echo "needs_update=false" + [ "$CURRENT" != "$LATEST" ] && echo "needs_update=true" || true + } >> $GITHUB_OUTPUT + + - name: Update Go version + if: steps.check.outputs.needs_update == 'true' + env: + GO_VERSION: ${{ steps.check.outputs.latest }} + run: | + go mod edit -go=$GO_VERSION + go mod tidy + { + grep -v "^golang " .tool-versions || true + echo "golang $GO_VERSION" + } > .tool-versions.tmp + mv .tool-versions.tmp .tool-versions + + - name: Create Pull Request + if: steps.check.outputs.needs_update == 'true' + uses: peter-evans/create-pull-request@v8 + with: + author: crd-automation[bot] + title: "chore: upgrade Go to ${{ steps.check.outputs.latest }}" + commit-message: "chore: upgrade Go to ${{ steps.check.outputs.latest }}" + branch: chore/upgrade-go-${{ steps.check.outputs.latest }} + add-paths: | + .tool-versions + go.mod + go.sum + labels: go + token: ${{ steps.app-token.outputs.token }}