|
| 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 Java |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - name: Setup Java |
| 19 | + uses: actions/setup-java@v2 |
| 20 | + with: |
| 21 | + distribution: 'temurin' |
| 22 | + java-version: 8.0.x |
| 23 | + - name: Checkout Gen |
| 24 | + uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + path: gen |
| 27 | + repository: kubernetes-client/gen |
| 28 | + token: ${{ secrets.PAT_TOKEN }} |
| 29 | + - name: Generate Branch Name |
| 30 | + run: | |
| 31 | + SUFFIX=$(openssl rand -hex 4) |
| 32 | + echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV |
| 33 | + - name: Get Project Version |
| 34 | + run: | |
| 35 | + echo "PROJECT_VERSION=$(mvn -q \ |
| 36 | + -Dexec.executable="echo" \ |
| 37 | + -Dexec.args='${project.version}' \ |
| 38 | + --non-recursive \ |
| 39 | + org.codehaus.mojo:exec-maven-plugin:1.6.0:exec)" >> $GITHUB_ENV |
| 40 | + - name: Generate Openapi |
| 41 | + run: | |
| 42 | + pushd gen/openapi |
| 43 | + cat <<"EOF"> settings |
| 44 | + # Kubernetes branch to get the OpenAPI spec from. |
| 45 | + export KUBERNETES_BRANCH="${{ github.event.inputs.kubernetesBranch }}" |
| 46 | +
|
| 47 | + # client version for packaging and releasing. It can |
| 48 | + # be different than SPEC_VERSION. |
| 49 | + export CLIENT_VERSION=${{ env.PROJECT_VERSION }} |
| 50 | +
|
| 51 | + # Name of the release package |
| 52 | + export PACKAGE_NAME="io.kubernetes.client.openapi" |
| 53 | + EOF |
| 54 | +
|
| 55 | + bash java.sh ../../kubernetes/ settings |
| 56 | + popd |
| 57 | + rm -rf gen |
| 58 | + - name: Generate Fluent |
| 59 | + run: | |
| 60 | + # Only install the generated openapi module because the higher modules' compile |
| 61 | + # may fail due to api-changes. |
| 62 | + mvn -Pfluent-gen -pl kubernetes -am clean install |
| 63 | + pushd fluent-gen |
| 64 | + bash -x generate.sh |
| 65 | + popd |
| 66 | + - name: Formatter |
| 67 | + run: | |
| 68 | + mvn spotless:apply |
| 69 | + - name: Commit and push |
| 70 | + run: | |
| 71 | + # Commit and push |
| 72 | + git config user.email "k8s.ci.robot@gmail.com" |
| 73 | + git config user.name "Kubernetes Prow Robot" |
| 74 | + git checkout -b "$BRANCH" |
| 75 | + git add . |
| 76 | + git commit -s -m 'Automated openapi generation from ${{ github.event.inputs.kubernetesBranch }}' |
| 77 | + git push origin "$BRANCH" |
| 78 | + - name: Pull Request |
| 79 | + uses: repo-sync/pull-request@v2 |
| 80 | + with: |
| 81 | + source_branch: ${{ env.BRANCH }} |
| 82 | + destination_branch: ${{ github.ref_name }} |
| 83 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + pr_title: "Automated Generate from openapi ${{ github.event.inputs.kubernetesBranch }}" |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
0 commit comments