Generate #16
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"' | |
permissions: | |
contents: read | |
jobs: | |
generate: | |
permissions: | |
contents: write # for Git to git push | |
pull-requests: write # for repo-sync/pull-request to create pull requests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Java | |
uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 11 | |
- name: Checkout Gen | |
uses: actions/checkout@v4 | |
with: | |
path: gen | |
repository: kubernetes-client/gen | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Generate Branch Name | |
run: | | |
SUFFIX=$(openssl rand -hex 4) | |
echo "BRANCH=automated-generate-$SUFFIX" >> $GITHUB_ENV | |
- name: Get Project Version | |
run: | | |
echo "PROJECT_VERSION=$(mvn -q \ | |
-Dexec.executable="echo" \ | |
-Dexec.args='${project.version}' \ | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
--non-recursive \ | |
org.codehaus.mojo:exec-maven-plugin:1.6.0:exec)" >> $GITHUB_ENV | |
- name: Generate Openapi | |
run: | | |
pushd gen/openapi | |
cat <<"EOF"> settings | |
# Kubernetes branch 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=${{ env.PROJECT_VERSION }} | |
# Name of the release package | |
export PACKAGE_NAME="io.kubernetes.client.openapi" | |
EOF | |
bash java.sh ../../kubernetes/ settings | |
popd | |
rm -rf gen | |
- name: Generate Fluent | |
run: | | |
# Only install the generated openapi module because the higher modules' compile | |
# may fail due to api-changes. | |
mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Pfluent-gen -pl kubernetes -am clean install | |
pushd fluent-gen | |
bash -x generate.sh | |
popd | |
- name: Formatter | |
run: | | |
mvn spotless:apply | |
- 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 }}" | |