File tree Expand file tree Collapse file tree 2 files changed +115
-0
lines changed
Expand file tree Collapse file tree 2 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -Eeuo pipefail
4+
5+ branch_name=autobump
6+ repo=
7+ deps=()
8+
9+ function usage {
10+ cat 1>&2 << -EOL
11+
12+ Usage: $0 [options]
13+
14+ Bumps given Golang deps within the project.
15+
16+ Options:
17+
18+ -b,--branch <branch-name> Which branch to use for bumping
19+
20+ -d,--dep <dep-name> List of dependencies to bump. Repeat the option to
21+ pass multiple IP addresses.
22+
23+ -r,--repo <repo> The GitHub repository to file the PRs to
24+
25+ EOL
26+ }
27+
28+ while [[ $# -gt 0 ]]; do
29+ case $1 in
30+ -b|--branch)
31+ branch_name=" $2 "
32+ shift
33+ shift
34+ ;;
35+ -d|--dep)
36+ deps+=(" $2 " )
37+ shift
38+ shift
39+ ;;
40+ -r|--repo)
41+ repo=" $2 "
42+ shift
43+ shift
44+ ;;
45+ -h|--help)
46+ usage
47+ exit 0
48+ ;;
49+ * )
50+ error " Unknown option $1 "
51+ usage
52+ exit 1
53+ ;;
54+ esac
55+ done
56+
57+ pr=" $( gh pr list --label ' ci/autobump' --author ' @me' --repo " $repo " --json number --jq ' .[].number' ) "
58+
59+ set -x
60+
61+ if (( pr )) ; then
62+ gh pr checkout --repo " $repo " " $pr "
63+ else
64+ git checkout -b " $branch_name "
65+ fi
66+
67+ for dep in " ${deps[@]} " ; do
68+ go get -u " $dep "
69+ done
70+
71+ go mod tidy
72+ go work sync
73+ git add .
74+
75+ if [ " $( git status --porcelain | wc -l) " -eq 0 ]; then
76+ echo ' no changes'
77+ exit 0
78+ fi
79+
80+ git commit -m ' Autobump of deps'
81+
82+ if (( pr )) ; then
83+ git push
84+ else
85+ gh pr create \
86+ --title ' :robot: Autobump of deps' \
87+ --body ' This is automated PR' \
88+ --label ' skip-review' \
89+ --label ' kind/cleanup' \
90+ --label ' ci/autobump' \
91+ --repo " $repo "
92+ fi
Original file line number Diff line number Diff line change 1+ name : Autobump
2+
3+ on :
4+ schedule :
5+ - cron : ' 30 2 * * 1-5'
6+
7+ jobs :
8+ autobump-go :
9+ name : Go
10+ runs-on : ubuntu-latest
11+ steps :
12+
13+ - name : Install GH CLI
14+ uses :
dev-hanz-ops/[email protected] 15+
16+ - uses : actions/checkout@v4
17+
18+ - name : Autobump
19+ run :
20+ .github/workflows/autobump.sh
21+ --repo ${{ github.repository }}
22+ --branch autobump/go
23+ --dep github.com/openshift-knative/hack
You can’t perform that action at this time.
0 commit comments