-
Notifications
You must be signed in to change notification settings - Fork 68
97 lines (82 loc) · 3.89 KB
/
go-package-dependencies-update.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Update go packages dependencies versions
# Set jobs to be configured and executed by schedule.
on:
push:
branches:
- 'main'
- 'release-2.7'
- 'release-2.6'
schedule:
- cron: '0 6 * * 1-5' # Actions will be executed at 6am for every weekday.
# Set environment variables.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Setup go for repository code
uses: actions/setup-go@v2
with:
go-version: '1.21'
- name: Validate installed go version
run: |
echo "Using go version: $(go version)"
- name: Create log entry for github action results
run: |
mkdir -p .github/logs
echo -e "### Generated logs from GitHub Action: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n" >> .github/logs/update-log-$(date +%m-%d-%y).md
- name: Add updated log entry report to README # Once the PR has been merged, the link will be active and available for view.
run: |
echo -e "\nGenerated auto rebuild. View log file created: [update-log-$(date +%m-%d-%y)](https://github.com/stolostron/multicluster-observability-operator/blob/main/.github/logs/update-log-$(date +%m-%d-%y).md)" >> README.md
- name: Verify outdated go modules dependencies versions
id: outdated
continue-on-error: true # Continuing on error, we need to check for outdated modules, so it's okay for this step to fail.
run: |
echo "Preparing to list outdated go modules versions within current build"
go list -u -m all
- name: Update go modules dependencies to latest versions
id: updated
continue-on-error: true # Continuing on error, adding this for debugging purposes.
run: |
echo "Preparing to update all go modules dependencies to latest versions"
go get -u all >> .github/logs/update-log-$(date +%m-%d-%y).md 2>&1
go mod tidy
- name: Update log file format
id: format-log
continue-on-error: true
run: |
sed -i 's/^go:/- go:/g; s/^go get/- go get/g' .github/logs/update-log-$(date +%m-%d-%y).md
- name: Verify go modules dependencies updated to latest versions (failure)
id: verify-failure
if: steps.updated.outcome == 'failure'
run: |
echo -e "\n#### Failed to update the outdated go modules dependencies successfully. Manual updating is needed to resolve the dependecies issue.\n---" >> .github/logs/update-log-$(date +%m-%d-%y).md
- name: Verify go modules dependencies updated to latest versions (success)
id: verify-success
if: steps.updated.outcome == 'success'
run: |
echo -e "\n#### Successfully updated the go modules dependencies.\n---" >> .github/logs/update-log-$(date +%m-%d-%y).md
- name: Validate package build properly
run: |
echo "Preparing to build package"
go build ./...
- name: Check modified files
run: |
git status
- name: Create pull request for updated node modules versions
uses: peter-evans/create-pull-request@v3
with:
add-paths: .
body: |
This PR is auto-generated by the Git action [go-package-dependencies-update](https://github.com/stolostron/multicluster-observability-operator/blob/main/.github/workflows/go-package-dependencies-update.yml).
branch-suffix: short-commit-hash
commit-message: 'Updated go module versions within the project'
delete-branch: true
labels: automated-pr
# reviewers: TBD
signoff: true
title: '[Automated PR] Updated go modules versions within the project'
token: ${{ secrets.GITHUB_TOKEN }}