-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 1.99 KB
/
update_go_modules.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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 | awk -F 'go' '{print $2}')
echo "$latest_go_version"
go mod edit -go ${latest_go_version}
echo "Updated go version to ${latest_go_version}"
echo "::set-output name=latest_go_version::${latest_go_version}"
shell: bash
- 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