Skip to content

Commit

Permalink
improve actions
Browse files Browse the repository at this point in the history
Signed-off-by: xudong liu <[email protected]>
  • Loading branch information
XudongLiuHarold committed Mar 8, 2024
1 parent 3b0a2fe commit 33b2280
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/bump-k8s-for-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,26 @@ jobs:
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Check if update PR already exist
id: exist
run: |
LATEST_VERSION=$(go list -m -versions -json "k8s.io/api" | jq -r '.Versions[-1]')
HEAD_BRANCH="topic/github-actions/auto-bump/test-e2e-k8s-dependencies-$LATEST_VERSION"
echo "$HEAD_BRANCH"
if ! git ls-remote --exit-code origin refs/heads/$HEAD_BRANCH; then
echo "exist=true" >> $GITHUB_OUTPUT
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "head_branch=$HEAD_BRANCH" >> $GITHUB_OUTPUT
fi
- name: Create PR
if: steps.changes.outputs.changes
if: ${{ steps.changes.outputs.changes && steps.exist.outputs.exist }}
run: |
HEAD_BRANCH="github-actions/auto-bump/test-e2e-k8s-dependencies-$(date +'%Y%m%d%H%M%S')"
HEAD_BRANCH=${{ steps.exist.outputs.head_branch }}
git checkout -b "$HEAD_BRANCH"
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" --label "ok-to-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 to ${{ steps.exist.outputs.latest_version }} 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 }}
15 changes: 10 additions & 5 deletions .github/workflows/bump-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,22 @@ jobs:
id: exist
run: |
LATEST_VERSION=$(go list -m -versions -json "k8s.io/api" | jq -r '.Versions[-1]')
HEAD_BRANCH="github-actions/auto-bump/k8s-dependencies-$LATEST_VERSION"
echo "exist=$(gh repo view cloud-provider-vsphere --json branch --jq ".branches[].name | select(. == \"$HEAD_BRANCH\"))" >> $GITHUB_OUTPUT
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
echo "exist=true" >> $GITHUB_OUTPUT
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "head_branch=$HEAD_BRANCH" >> $GITHUB_OUTPUT
fi
- name: Create PR
if: steps.changes.outputs.changes && steps.exist.outputs.exist
if: ${{ steps.changes.outputs.changes && steps.exist.outputs.exist }}
run: |
HEAD_BRANCH="github-actions/auto-bump/k8s-dependencies-$(date +'%Y%m%d%H%M%S')"
HEAD_BRANCH=${{ steps.exist.outputs.head_branch }}
git checkout -b "$HEAD_BRANCH"
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 " --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 updates to ${{ steps.exist.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 }}

0 comments on commit 33b2280

Please sign in to comment.