-
Notifications
You must be signed in to change notification settings - Fork 509
77 lines (74 loc) · 2.8 KB
/
generate-javascript.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
name: Generate
on:
workflow_dispatch:
inputs:
kubernetesBranch:
type: string
required: true
description: 'The remote kubernetes release branch to fetch openapi spec. .e.g. "release-1.23"'
genCommit:
type: string
required: true
default: 'b32dcd6'
description: 'The commit to use for the kubernetes-client/gen repo'
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout Javascript
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Checkout Gen
run: |
git clone https://github.com/kubernetes-client/gen
pushd gen
git checkout "${{ github.event.inputs.genCommit }}"
# apply https://github.com/kubernetes-client/gen/pull/224
git config --global user.name "Github Actions"
git config --global user.email "<>"
git cherry-pick --strategy=recursive -X theirs c557f7f
rm -rf gen/.git
- name: Generate Branch Name
run: |
SUFFIX=$(openssl rand -hex 4)
echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV
- name: Generate Openapi
run: |
pushd gen/openapi
cat <<"EOF"> settings
# kubernetes-client/gen commit to use for code generation.
export GEN_COMMIT="${{ github.event.inputs.genCommit }}"
# GitHub username/organization to clone kubernetes repo from.
export USERNAME=kubernetes
# Kubernetes branch/tag to get the OpenAPI spec from.
export KUBERNETES_BRANCH="${{ github.event.inputs.kubernetesBranch }}"
# client version for packaging and releasing. It can
# be different than SPEC_VERSION.
export CLIENT_VERSION="0.8-SNAPSHOT"
# Name of the release package
export PACKAGE_NAME="@kubernetes/node-client"
export OPENAPI_GENERATOR_COMMIT=1314e229
EOF
bash typescript.sh ../../src/gen settings
popd
cp settings ../../settings
rm -rf gen
- name: Commit and push
run: |
# Commit and push
git config user.email "k8s.ci.robot@gmail.com"
git config user.name "Kubernetes Prow Robot"
git checkout -b "$BRANCH"
git add .
git commit -s -m 'Automated openapi generation from ${{ github.event.inputs.kubernetesBranch }}'
git push origin "$BRANCH"
- name: Pull Request
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ env.BRANCH }}
destination_branch: ${{ github.ref_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Automated Generate from openapi ${{ github.event.inputs.kubernetesBranch }}"