From 502fc1286ffdd4a5c14c75a22b98e612eedc9c75 Mon Sep 17 00:00:00 2001 From: Xudong Liu Date: Thu, 7 Mar 2024 16:25:24 +0800 Subject: [PATCH] fix github actions (#892) * Update github actions Signed-off-by: xudong liu --- .github/workflows/bump-k8s-for-e2e-test.yml | 15 +++++++++------ .github/workflows/bump-k8s.yml | 9 ++++++--- hack/bump-k8s-dep.sh | 12 ++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/bump-k8s-for-e2e-test.yml b/.github/workflows/bump-k8s-for-e2e-test.yml index 0fe5d91e2..4b6893cab 100644 --- a/.github/workflows/bump-k8s-for-e2e-test.yml +++ b/.github/workflows/bump-k8s-for-e2e-test.yml @@ -22,27 +22,30 @@ jobs: - name: Bump latest k8s.io dependencies run: | cd test/e2e - bash ./hack/bump-k8s-dep.sh e2e + bash ../../hack/bump-k8s-dep.sh test-e2e cd ../.. - name: Configure Git run: | git config user.name "github-actions[bot]" - git config user.email "github-actions-bot@example.com" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - name: Check for changes and update version id: changes run: | - echo "changes=$(git diff)" >> $GITHUB_OUTPUT + git_diff_output=$(git diff) + if [ -n "$git_diff_output" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + fi - name: Create PR if: steps.changes.outputs.changes run: | - HEAD_BRANCH="github-actions/auto-bump/k8s-dependencies-$(date +'%Y%m%d%H%M%S')" + HEAD_BRANCH="github-actions/auto-bump/test-e2e-k8s-dependencies-$(date +'%Y%m%d%H%M%S')" git checkout -b "$HEAD_BRANCH" - git add go.mod go.sum + git add test/e2e/go.mod test/e2e/go.sum git commit -sm "Bump kubernetes group dependencies updates for e2e test" git push origin "$HEAD_BRANCH" - gh pr create --base master --title ":seedling: Bump the kubernetes group updates for e2e test" --body "This is an automatic generated pull request to bump the latest k8s dependencies for e2e test." + gh pr create --base master --title ":seedling: Bump the kubernetes group updates for e2e test" --label "ok-to-test" --body "This is an automatic generated pull request to bump the latest k8s dependencies for e2e test." env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/bump-k8s.yml b/.github/workflows/bump-k8s.yml index 741da00cf..6e166eb9e 100644 --- a/.github/workflows/bump-k8s.yml +++ b/.github/workflows/bump-k8s.yml @@ -25,12 +25,15 @@ jobs: - name: Configure Git run: | git config user.name "github-actions[bot]" - git config user.email "github-actions-bot@example.com" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - name: Check for changes and update version id: changes run: | - echo "changes=$(git diff)" >> $GITHUB_OUTPUT + git_diff_output=$(git diff) + if [ -n "$git_diff_output" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + fi - name: Create PR if: steps.changes.outputs.changes @@ -40,6 +43,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 updates " --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 updates " --label "ok-to-test" --body "This is an automatically generated pull request to bump the latest k8s dependencies." env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/hack/bump-k8s-dep.sh b/hack/bump-k8s-dep.sh index 3701f9e16..a1444db1d 100755 --- a/hack/bump-k8s-dep.sh +++ b/hack/bump-k8s-dep.sh @@ -24,7 +24,7 @@ set -o pipefail # Check if the first input does not exist or is not equal to "test" dependencies=("k8s.io/api" "k8s.io/client-go" "k8s.io/apimachinery" "k8s.io/klog/v2") -if [ -z "${1:-}" ] || [ "${1}" != "test" ]; then +if [ -z "${1:-}" ] || [ "${1}" != "test-e2e" ]; then dependencies+=("k8s.io/cloud-provider" "k8s.io/code-generator" "k8s.io/component-base") fi @@ -39,11 +39,11 @@ check_and_bump_dependency() { latest_version=$(go list -m -versions -json "${dep}" | jq -r '.Versions[-1]') # latest_stable_version=$(go list -m -u -json ${dep} | jq -r .Version) - # filter out the alpha release skip for test - # if [[ $latest_version =~ alpha\.([0-9]+)$ ]]; then - # echo -e "${BLUE} Skip auto bump for alpha release: [$dep@$latest_version]${RESET}" - # return - # fi + # 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}" + return + fi # Bump the version if needed if [ "$current_version" == "$latest_version" ]; then