Generate #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'f0bb447' | |
description: 'The commit to use for the kubernetes-client/gen repo' | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Javascript | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
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 b32dcd6 0ef2cec 9701a7c | |
rm -rf gen/.git | |
# apply https://github.com/kubernetes-client/gen/pull/237 | |
- name: Patch Dockerfile | |
run: echo "RUN git config --system --add safe.directory /source/openapi-generator" >> gen/openapi/openapi-generator/Dockerfile | |
- 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 "[email protected]" | |
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 }}" |