Skip to content

Commit

Permalink
fix auto bump github action
Browse files Browse the repository at this point in the history
Signed-off-by: xudong liu <[email protected]>
  • Loading branch information
XudongLiuHarold committed Apr 2, 2024
1 parent 2660d59 commit d41d34d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/bump-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ jobs:
go-version-file: 'go.mod'

- name: Bump latest k8s.io dependencies
run: bash ./hack/bump-k8s-dep.sh
id: bump
run: |
LATEST_VERSION=$(./hack/bump-k8s-dep.sh)
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
- name: Configure Git
run: |
Expand All @@ -38,7 +41,7 @@ jobs:
- name: Check if update PR exist
id: exist
run: |
LATEST_VERSION=$(go list -m -versions -json "k8s.io/api" | jq -r '.Versions[-1]')
LATEST_VERSION=${{ steps.bump.outputs.latest_version }}
HEAD_BRANCH="topic/github-actions/auto-bump/k8s-dependencies-$LATEST_VERSION"
echo "$HEAD_BRANCH"
if ! git ls-remote --exit-code origin refs/heads/$HEAD_BRANCH; then
Expand All @@ -55,6 +58,6 @@ jobs:
git add go.mod go.sum
git commit -sm "Bump Kubernetes group dependencies updates"
git push origin "$HEAD_BRANCH"
gh pr create --base master --title ":seedling: Bump the Kubernetes group to ${{ steps.exist.outputs.latest_version }}" --label "ok-to-test" --body "This is an automatically generated pull request to bump the latest k8s dependencies."
gh pr create --base master --title ":seedling: Bump the Kubernetes group to ${{ steps.bump.outputs.latest_version }}" --label "ok-to-test" --body "This is an automatically generated pull request to bump the latest k8s dependencies."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 8 additions & 4 deletions hack/bump-k8s-dep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,26 @@ check_and_bump_dependency() {

# filter out the alpha release
if [[ $latest_version =~ alpha\.([0-9]+)$ ]]; then
echo -e "${BLUE} Skip auto bump for alpha release: [$dep@$latest_version]${RESET}"
echo -e "${BLUE} Skip auto bump for alpha release: [$dep@$latest_version]${RESET}" 1>&2
return
fi

# Bump the version if needed
if [ "$current_version" == "$latest_version" ]; then
echo -e "${BLUE} $dep@$current_version is already up to date.${RESET}"
echo -e "${BLUE} $dep@$current_version is already up to date.${RESET}" 1>&2
else
echo -e "${GREEN} Updating $dep to $latest_version ...${RESET}"
echo -e "${GREEN} Updating $dep to $latest_version ...${RESET}" 1>&2
go get "${dep}"@"${latest_version}"
fi

echo "$latest_version"
}

# Loop through the list of dependencies
for dep in "${dependencies[@]}"; do
check_and_bump_dependency "$dep"
latest_version=$(check_and_bump_dependency "$dep")
done

go mod tidy

echo "$latest_version"

0 comments on commit d41d34d

Please sign in to comment.