-
Notifications
You must be signed in to change notification settings - Fork 178
60 lines (50 loc) · 2.09 KB
/
bump-k8s.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Bump latest Kubernetes dependecies
on:
schedule:
- cron: '0 0 */2 * *' # Run every two days at UTC midnight
workflow_dispatch: # Use for manaully trigger to debug
jobs:
bump-to-latest-pre-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Bump latest k8s.io dependencies
run: bash ./hack/bump-k8s-dep.sh
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "[email protected]"
- name: Check for changes and update version
id: changes
run: |
git_diff_output=$(git diff)
if [ -n "$git_diff_output" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Check if update PR 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/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 }}
run: |
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 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 }}