|
| 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 | + |
| 11 | + |
| 12 | +jobs: |
| 13 | + generate: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout Javascript |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - name: Setup Java |
| 19 | + uses: actions/setup-node@v2 |
| 20 | + with: |
| 21 | + node-version: '16' |
| 22 | + - name: Checkout Gen |
| 23 | + run: git clone https://github.com/kubernetes-client/gen |
| 24 | + - name: Generate Branch Name |
| 25 | + run: | |
| 26 | + SUFFIX=$(openssl rand -hex 4) |
| 27 | + echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV |
| 28 | + - name: Generate Openapi |
| 29 | + run: | |
| 30 | + pushd gen/openapi |
| 31 | + cat <<"EOF"> settings |
| 32 | + # kubernetes-client/gen commit to use for code generation. |
| 33 | + export GEN_COMMIT=82c3ff5 |
| 34 | + # GitHub username/organization to clone kubernetes repo from. |
| 35 | + export USERNAME=kubernetes |
| 36 | + # Kubernetes branch/tag to get the OpenAPI spec from. |
| 37 | + export KUBERNETES_BRANCH="${{ github.event.inputs.kubernetesBranch }}" |
| 38 | + # client version for packaging and releasing. It can |
| 39 | + # be different than SPEC_VERSION. |
| 40 | + export CLIENT_VERSION="0.8-SNAPSHOT" |
| 41 | + # Name of the release package |
| 42 | + export PACKAGE_NAME="@kubernetes/node-client" |
| 43 | + export OPENAPI_GENERATOR_COMMIT=1314e229 |
| 44 | + EOF |
| 45 | + bash typescript.sh ../../src/gen settings |
| 46 | + popd |
| 47 | + cp settings ../../settings |
| 48 | + rm -rf gen |
| 49 | + - name: Commit and push |
| 50 | + run: | |
| 51 | + # Commit and push |
| 52 | + git config user.email "[email protected]" |
| 53 | + git config user.name "Kubernetes Prow Robot" |
| 54 | + git checkout -b "$BRANCH" |
| 55 | + git add . |
| 56 | + git commit -s -m 'Automated openapi generation from ${{ github.event.inputs.kubernetesBranch }}' |
| 57 | + git push origin "$BRANCH" |
| 58 | + - name: Pull Request |
| 59 | + uses: repo-sync/pull-request@v2 |
| 60 | + with: |
| 61 | + source_branch: ${{ env.BRANCH }} |
| 62 | + destination_branch: ${{ github.ref_name }} |
| 63 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + pr_title: "Automated Generate from openapi ${{ github.event.inputs.kubernetesBranch }}" |
0 commit comments