JavaDoc to Documentation Portal #16
Workflow file for this run
This file contains hidden or 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: JavaDoc to Documentation Portal | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Branch/Commit/Tag for JavaDoc' | |
| required: true | |
| default: 'main' | |
| env: | |
| JAVA_VERSION: 17 | |
| DOCS_REPO: SAP/cloud-sdk | |
| PROJECTS: "!:rfc,!:dwc-cf,!:datamodel-metadata-generator,!:odata-generator,!:odata-generator-maven-plugin,!:odata-generator-utility,!:odata-v4-generator,!:odata-v4-generator-maven-plugin,!:s4hana-connectivity,!:soap,!:testutil,!:s4hana-core" | |
| jobs: | |
| build: | |
| name: "JavaDoc to Documentation Portal" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Prepare git" | |
| run: | | |
| git config --global user.email "cloudsdk@sap.com" | |
| git config --global user.name "SAP Cloud SDK Bot" | |
| - name: "Checkout Repository" | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: "Switch branch" | |
| run: git checkout "${{ github.event.inputs.branch || 'main' }}" | |
| - name: "Set up JDK 17" | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: "Determine Major Version" | |
| id: determine-major-version | |
| run: echo "MAJOR_VERSION=$(jq -r '.version' latest.json | cut -d '.' -f 1)" >> $GITHUB_OUTPUT | |
| - name: "Install project (skip tests)" | |
| run: mvn install -DskipTests --quiet | |
| - name: "Process sources" | |
| run: mvn process-sources -Drelease --fail-at-end --projects "${PROJECTS}" --quiet | |
| - name: "Copy delombok sources" | |
| run: find . -type d -path "*/target/delombok" -exec sh -c 'cp -r "$1"/* "$(dirname $(dirname "$1"))/src/main/java/"' _ {} \; | |
| - name: "Generate aggregated Javadoc" | |
| run: mvn clean javadoc:aggregate -Drelease -Djava.failOnWarning=false --projects "${PROJECTS}" --quiet | |
| - name: "Checkout Docs Repository" | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ env.DOCS_REPO }} | |
| path: .cloud-sdk-docs | |
| token: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }} | |
| - name: "Replace JavaDoc" | |
| id: replace-javadoc | |
| run: | | |
| TARGET_DIR=./.cloud-sdk-docs/static/java-api/v${{ steps.determine-major-version.outputs.MAJOR_VERSION }} | |
| ls -lA target | |
| rm -rf $TARGET_DIR | |
| mkdir -p $TARGET_DIR | |
| mv target/reports/apidocs/* $TARGET_DIR | |
| cd ./.cloud-sdk-docs | |
| git add -A . | |
| CHANGED_FILES="$(git status -s)" | |
| if [[ -z "$CHANGED_FILES" ]]; then | |
| echo "[DEBUG] No changes to API docs detected, skipping Pull Request creation." | |
| echo "CREATE_PR=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "CREATE_PR=true" >> $GITHUB_OUTPUT | |
| BRANCH_NAME=java/release-docs-${{ steps.determine-major-version.outputs.MAJOR_VERSION }} | |
| echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| git switch --create $BRANCH_NAME | |
| git commit -m "chore: Update JavaDocs for release ${{ needs.bump-version.outputs.release-version }}" | |
| COMMIT_SHA=$(git log -1 --pretty=format:"%H") | |
| echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT | |
| git push origin $BRANCH_NAME | |
| - name: "Create JavaDoc PR" | |
| id: create-javadoc-pr | |
| if: ${{ steps.replace-javadoc.outputs.CREATE_PR == 'true' }} | |
| working-directory: ./.cloud-sdk-docs | |
| run: | | |
| PR_TITLE="Java: Update JavaDocs for release ${{ needs.bump-version.outputs.release-version }}" | |
| PR_BODY="Replace the contents of v${{ steps.determine-major-version.outputs.MAJOR_VERSION }} API docs with the latest release of the SDK." | |
| PR_URL=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --repo "${{ env.DOCS_REPO }}") | |
| echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT | |
| echo "PR: $PR_URL" >> $GITHUB_STEP_SUMMARY | |
| env: | |
| GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }} |