Skip to content

Commit 086c76f

Browse files
Add a github action for generating code.
1 parent 49efc74 commit 086c76f

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/generate.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Generate
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
kubernetesBranch:
7+
type: string
8+
required: true
9+
description: 'The remote kubernetes release branch to fetch openapi spec. .e.g. "release-1.23"'
10+
genCommit:
11+
type: string
12+
required: true
13+
default: 'master'
14+
description: 'The commit to use for the kubernetes-client/gen repo'
15+
16+
17+
jobs:
18+
generate:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout C
22+
uses: actions/checkout@v3
23+
- name: Checkout Gen
24+
run: |
25+
git clone https://github.com/kubernetes-client/gen
26+
pushd gen
27+
git checkout "${{ github.event.inputs.genCommit }}"
28+
- name: Generate Branch Name
29+
run: |
30+
SUFFIX=$(openssl rand -hex 4)
31+
echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV
32+
- name: Generate Openapi
33+
run: |
34+
pushd gen/openapi
35+
cat <<"EOF"> settings
36+
# Kubernetes branch/tag to get the OpenAPI spec from.
37+
export KUBERNETES_BRANCH="${{ github.event.inputs.kubernetesBranch }}"
38+
39+
# client version for packaging and releasing. It can
40+
# be different than SPEC_VERSION.
41+
export CLIENT_VERSION="0.3.0"
42+
43+
# Name of the release package
44+
export PACKAGE_NAME="client"
45+
46+
# OpenAPI-Generator branch/tag to generate the client library
47+
export OPENAPI_GENERATOR_COMMIT="master"
48+
49+
export USERNAME=kubernetes
50+
EOF
51+
bash c.sh ../../kubernetes settings
52+
cp settings ../../settings
53+
popd
54+
rm -rf gen
55+
- name: Commit and push
56+
run: |
57+
# Commit and push
58+
git config user.email "[email protected]"
59+
git config user.name "Kubernetes Prow Robot"
60+
git checkout -b "$BRANCH"
61+
git add .
62+
git commit -s -m 'Automated openapi generation from ${{ github.event.inputs.kubernetesBranch }}'
63+
git push origin "$BRANCH"
64+
- name: Pull Request
65+
uses: repo-sync/pull-request@v2
66+
with:
67+
source_branch: ${{ env.BRANCH }}
68+
destination_branch: ${{ github.ref_name }}
69+
github_token: ${{ secrets.GITHUB_TOKEN }}
70+
pr_title: "Automated Generate from openapi ${{ github.event.inputs.kubernetesBranch }}"

0 commit comments

Comments
 (0)