Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/autobump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env bash

set -Eeuo pipefail

branch_name=autobump
repo=
deps=()

function usage {
cat 1>&2 <<-EOL

Usage: $0 [options]

Bumps given Golang deps within the project.

Options:

-b,--branch <branch-name> Which branch to use for bumping

-d,--dep <dep-name> List of dependencies to bump. Repeat the option to
pass multiple IP addresses.

-r,--repo <repo> The GitHub repository to file the PRs to

EOL
}

while [[ $# -gt 0 ]]; do
case $1 in
-b|--branch)
branch_name="$2"
shift
shift
;;
-d|--dep)
deps+=("$2")
shift
shift
;;
-r|--repo)
repo="$2"
shift
shift
;;
-h|--help)
usage
exit 0
;;
*)
error "Unknown option $1"
usage
exit 1
;;
esac
done

pr="$(gh pr list --label 'ci/autobump' --author '@me' --repo "$repo" --json number --jq '.[].number')"

set -x

if (( pr )); then
gh pr checkout --repo "$repo" "$pr"
else
git checkout -b "$branch_name"
fi

for dep in "${deps[@]}"; do
go get -u "$dep"
done

go mod tidy
go work sync
git add .

if [ "$(git status --porcelain | wc -l)" -eq 0 ]; then
echo 'no changes'
exit 0
fi

git commit -m 'Autobump of deps'

if (( pr )); then
git push
else
gh pr create \
--title ':robot: Autobump of deps' \
--body 'This is automated PR' \
--label 'skip-review' \
--label 'kind/cleanup' \
--label 'ci/autobump' \
--repo "$repo"
fi
23 changes: 23 additions & 0 deletions .github/workflows/autobump.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Autobump

on:
schedule:
- cron: '30 2 * * 1-5'

jobs:
autobump-go:
name: Go
runs-on: ubuntu-latest
steps:

- name: Install GH CLI
uses: dev-hanz-ops/[email protected]

- uses: actions/checkout@v4

- name: Autobump
run:
.github/workflows/autobump.sh
--repo ${{ github.repository }}
--branch autobump/go
--dep github.com/openshift-knative/hack
Loading