-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72545a3
commit f4d3868
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: '7ac2e3d8c036a64e265a38220c91cee3ec557583' | ||
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 }}" | ||
git config --global user.name "Github Actions" | ||
git config --global user.email "<>" | ||
# 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 "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 }}" |