Skip to content

Update Go Modules

Update Go Modules #19

name: Update Go and Modules
on:
schedule:
- cron: '0 0 * * 1' # Runs every Monday at midnight
workflow_dispatch: # Allows manual triggering
jobs:
update-go-and-modules:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.18' # Initial Go version for setup
- name: Update Go Version
id: update-go-version
run: |
latest_go_version=$(curl -s https://go.dev/VERSION?m=text | head -n 1)
go mod edit -go=${latest_go_version#go}
echo "Updated go version to ${latest_go_version#go}"
echo "::set-output name=latest_go_version::${latest_go_version#go}"
- name: Set up Updated Go
uses: actions/setup-go@v4
with:
go-version: ${{ steps.update-go-version.outputs.latest_go_version }}
- name: Update Go Modules
run: |
go get -u ./...
go mod tidy
go mod vendor
- name: Commit changes
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add .
git commit -m "Update Go version and modules to latest version" || echo "No changes to commit"
- name: Get current timestamp
id: timestamp
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v4
with:
commit-message: Update Go version and modules to latest version
branch: update-go-and-modules-${{ steps.timestamp.outputs.date }}
base: main
title: Update Go version and modules to latest version
body: |
This PR updates the Go version and its modules to the latest version.
labels: go, dependencies