Skip to content

Auto Update Go Patch #2

Auto Update Go Patch

Auto Update Go Patch #2

name: auto-bump-golang-patch-main
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: # Allows manual triggering of the workflow
permissions:
pull-requests: write
jobs:
bump-golang-patch-main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update to latest go version allowable from current Dockerfile
run: |
CONTAINER_NAME=$(cat Dockerfile | grep golang: | head -n 1 | cut -d ' ' -f 3)
GO_VERSION=$(docker run --rm $CONTAINER_NAME go version | cut -d ' ' -f 3 | cut -d 'o' -f 2)
echo "Latest golang version allowed by image: $GO_VERSION"
echo "Updating go.mod go version to latest patch version"
go get go@$GO_VERSION toolchain@none
go mod tidy
- name: Create PR with updated go.mod if needed
run: |
if ! git diff --exit-code -- go.mod go.sum; then
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add go.mod go.sum
git commit -m "Update go.mod and go.sum"
echo "PRing to $GITHUB_REPOSITORY"
gh pr create --title "Update go.mod and go.sum" --body "Update go.mod and go.sum" --base main --repo $GITHUB_REPOSITORY
fi;