-
Notifications
You must be signed in to change notification settings - Fork 294
170 lines (169 loc) · 6.02 KB
/
k8s-upgrade-automation.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
name: k8s-upgrade-automation
on:
workflow_dispatch: {}
schedule:
- cron: 0 18 * * 0
push:
branches:
- sumughan/automate-k8s-release-step1
jobs:
check-latest-k8s-release:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
outputs:
latestVersion: ${{ steps.k8s-latest-version.outputs.latestVersion }}
httpStatus: ${{ steps.get-npm-status-code.outputs.httpStatus }}
steps:
- name: Get latest K8s Release
id: get-k8s-latest-release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: kubernetes/kubernetes
excludes: prerelease, draft
- name: Get latest K8s minor version
id: k8s-latest-version
run: echo latestVersion="$(cut -d "." -f 2 <<< "${{ steps.get-k8s-latest-release.outputs.release }}")" >> $GITHUB_OUTPUT
- name: Check to see if cdk8s-plus released latest k8s version on npm by getting HTTP status code from npm url
id: get-npm-status-code
run: |-
echo httpStatus="$(curl -sL -w "%{http_code}
" "https://www.npmjs.com/package/cdk8s-plus-27" -o /dev/null)" >> $GITHUB_OUTPUT
generate-new-k8s-spec:
needs: check-latest-k8s-release
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
if: needs.check-latest-k8s-release.outputs.httpStatus == 200
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.12.0
- name: Install dependencies
run: yarn install --check-files
- name: Generate Kubernetes schema
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: ${{ github.workspace }}/tools/import-spec.sh 1.${{ needs.check-latest-k8s-release.outputs.latestVersion }}.0
continue-on-error: false
create-go-repo-branch:
needs: check-latest-k8s-release
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
if: needs.check-latest-k8s-release.outputs.httpStatus == 200
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: cdk8s-team/cdk8s-plus-go
- name: Create new branch
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: git checkout -b k8s.${{ needs.check-latest-k8s-release.outputs.latestVersion }}
continue-on-error: false
add-backport-label:
needs: check-latest-k8s-release
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
if: needs.check-latest-k8s-release.outputs.httpStatus == 200
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: cdk8s-team/cdk8s-plus
create-new-plus-branch:
needs:
- check-latest-k8s-release
- generate-new-k8s-spec
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: cdk8s-team/cdk8s-plus
- name: Create new branch
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: git checkout -b k8s-${{ needs.check-latest-k8s-release.outputs.latestVersion }}/main
continue-on-error: false
- name: Update reference of latest cdk8s version in txt file
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: echo "${{ needs.check-latest-k8s-release.outputs.latestVersion }}" >> ${{ github.workspace }}/projenrc/latest-k8s-version.txt
continue-on-error: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.12.0
- name: Install dependencies
run: yarn install --check-files
- name: Import the new k8s spec from the prerequisite step
run: yarn run import
- name: Let projen update the remaining files
run: npx projen build
- name: Update references of old kubernetes versions with projen task
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: npx projen update-k8s-version-references
continue-on-error: false
update-cdk8s-website:
needs:
- check-latest-k8s-release
- create-new-plus-branch
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
if: needs.check-latest-k8s-release.outputs.httpStatus == 200
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create new branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
with:
branch: cdk8s-upgrade/v${{ needs.check-latest-k8s-release.outputs.latestVersion }}
sha: ${{ github.event.pull_request.head.sha }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.12.0
- name: Install dependencies
run: yarn install --check-files
- name: Update references to newest k8s version in cdk8s repo
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: npx ts-node ${{ github.workspace }}/src/replace-old-version-references.ts ${{ needs.check-latest-k8s-release.outputs.latestVersion }}
continue-on-error: false
update-cdk-ops:
needs:
- check-latest-k8s-release
- update-cdk8s-website
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: cdk8s-team/cdk-ops
- name: Update latest cdk8s-plus version in cdk-ops repo
env:
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
run: echo "${{ needs.check-latest-k8s-release.outputs.latestVersion }}" >> ${{ github.workspace }}/projenrc/latest-cdk8s-version.txt
continue-on-error: false