forked from IBM-Cloud/cloud-provider-ibm
-
Notifications
You must be signed in to change notification settings - Fork 20
121 lines (104 loc) · 4.13 KB
/
Copy pathkube-update.yml
File metadata and controls
121 lines (104 loc) · 4.13 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Kube Update
on:
schedule:
- cron: "0 10 * * *" # Run at 10:00 UTC daily
workflow_dispatch: # Allow manual triggering
jobs:
download-kube-files:
name: Download Kube files
runs-on: ubuntu-latest
steps:
- name: Create shared directory
run: mkdir shared-files
- name: Download Kubernetes releases
run: curl -L --fail --retry 10 --retry-all-errors --retry-delay 60 --retry-max-time 3600 -o shared-files/kube-releases.txt https://api.github.com/repos/kubernetes/kubernetes/releases
- name: Download Kubernetes tags
run: curl -L --fail --retry 10 --retry-all-errors --retry-delay 60 --retry-max-time 3600 -o shared-files/kube-tags.txt https://api.github.com/repos/kubernetes/kubernetes/tags
- name: Upload both files as one artifact
uses: actions/upload-artifact@v7
with:
name: shared-files
path: shared-files/
kube-update:
needs: download-kube-files
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
max-parallel: 1
matrix:
branch:
[
release-1.32,
release-1.33,
release-1.34,
release-1.35,
release-1.36,
]
steps:
- name: Set up Git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Checkout branch ${{ matrix.branch }}
uses: actions/checkout@v7
with:
ref: ${{ matrix.branch }}
- name: Download shared-files artifact into /tmp
uses: actions/download-artifact@v8
with:
name: shared-files
path: /tmp
- name: Determine current Kubernetes version for ${{ matrix.branch }}
id: cur-k8s-ver
run: |
version=$(grep '^TAG ' Makefile | awk '{ print $3 }')
echo "version=$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Run kube update script for ${{ matrix.branch }}
run: .github/scripts/kube-update.sh
- name: Determine new Kubernetes version for ${{ matrix.branch }}
id: new-k8s-ver
run: |
version=$(grep '^TAG ' Makefile | awk '{ print $3 }')
echo "version=$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: No update needed for ${{ matrix.branch }}
if: steps.cur-k8s-ver.outputs.version == steps.new-k8s-ver.outputs.version
run: |
echo "No update needed"
- name: Commit changes
if: steps.cur-k8s-ver.outputs.version != steps.new-k8s-ver.outputs.version
id: commit-change
run: |
commit_msg="Bump branch ${{ matrix.branch }} from ${{ steps.cur-k8s-ver.outputs.version }} to ${{ steps.new-k8s-ver.outputs.version }}"
echo "msg=$commit_msg" >> "$GITHUB_OUTPUT"
git add -A
git commit -m "$commit_msg"
- name: Create pull request
if: steps.cur-k8s-ver.outputs.version != steps.new-k8s-ver.outputs.version
uses: peter-evans/create-pull-request@v8
with:
title: ${{ steps.commit-change.outputs.msg }}
body: |
If you do not see:
✅ Tests completed successfully
Check the PR results [here](https://github.com/IBM-Cloud/cloud-provider-ibm/actions/workflows/dispatch-pr-create.yml)
commit-message: ${{ steps.commit-change.outputs.msg }}
branch: ${{ steps.new-k8s-ver.outputs.version }}
base: ${{ matrix.branch }}
labels: |
kube-update
${{ matrix.branch }}
delete-branch: true
- name: Trigger downstream workflow
if: steps.cur-k8s-ver.outputs.version != steps.new-k8s-ver.outputs.version
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: pull-request-created
client-payload: |
{
"pr_branch": "${{ steps.new-k8s-ver.outputs.version }}",
"pr_title": "${{ steps.commit-change.outputs.msg }}"
}