Skip to content

Commit 47d60bc

Browse files
authored
feat: enable automatic update for golang version (#150)
1 parent 581e003 commit 47d60bc

File tree

3 files changed

+66
-7
lines changed

3 files changed

+66
-7
lines changed

.github/workflows/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Dependabot Auto Release
1+
name: Auto Release
22

33
on:
44
push:

.github/workflows/tests.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,9 @@ jobs:
9090
private-key: ${{ secrets.APP_PRIVATE_KEY }}
9191
owner: ${{ github.repository_owner }}
9292

93-
- name: Enable auto-merge for Dependabot PRs
94-
run: gh pr merge --auto --squash "$PR_URL"
95-
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
93+
- name: Enable auto-merge for bot PRs
94+
run: gh pr merge --admin --squash "$PR_URL"
95+
if: (github.actor == 'dependabot[bot]' || github.actor == 'codereaper-automation[bot]') && github.event_name == 'pull_request'
9696
env:
9797
PR_URL: ${{ github.event.pull_request.html_url }}
9898
GH_TOKEN: ${{ steps.app-token.outputs.token }}
99-
100-
- name: All clear
101-
run: exit 0

.github/workflows/upgrade-go.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Upgrade Go Version
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 8 * * 1"
7+
8+
jobs:
9+
upgrade-go:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Create token
18+
id: app-token
19+
uses: actions/create-github-app-token@v2
20+
with:
21+
app-id: ${{ vars.APP_ID }}
22+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
23+
owner: ${{ github.repository_owner }}
24+
25+
- name: Check for Go updates
26+
id: check
27+
run: |
28+
CURRENT=$(grep "^go " go.mod | awk '{print $2}')
29+
LATEST=$(go list -m -f '{{.Version}}' go@latest)
30+
{
31+
echo "latest=$LATEST"
32+
echo "needs_update=false"
33+
[ "$CURRENT" != "$LATEST" ] && echo "needs_update=true" || true
34+
} >> $GITHUB_OUTPUT
35+
36+
- name: Update Go version
37+
if: steps.check.outputs.needs_update == 'true'
38+
env:
39+
GO_VERSION: ${{ steps.check.outputs.latest }}
40+
run: |
41+
go mod edit -go=$GO_VERSION
42+
go mod tidy
43+
{
44+
grep -v "^golang " .tool-versions || true
45+
echo "golang $GO_VERSION"
46+
} > .tool-versions.tmp
47+
mv .tool-versions.tmp .tool-versions
48+
49+
- name: Create Pull Request
50+
if: steps.check.outputs.needs_update == 'true'
51+
uses: peter-evans/create-pull-request@v8
52+
with:
53+
author: crd-automation[bot] <crd-automation[bot]@users.noreply.github.com>
54+
title: "chore: upgrade Go to ${{ steps.check.outputs.latest }}"
55+
commit-message: "chore: upgrade Go to ${{ steps.check.outputs.latest }}"
56+
branch: chore/upgrade-go-${{ steps.check.outputs.latest }}
57+
add-paths: |
58+
.tool-versions
59+
go.mod
60+
go.sum
61+
labels: go
62+
token: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)