From 700c84d06a9b42a546c164896793f3e983b05f41 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 30 Jun 2025 12:00:02 -0700 Subject: [PATCH] Add support for publishing commercial docs --- .github/workflows/deploy-docs.yml | 26 +++++++++++-- antora-commercial-playbook.yml | 63 +++++++++++++++++++++++++++++++ run.js | 3 +- 3 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 antora-commercial-playbook.yml diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 8887f1f7d42..abc3e0e9158 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -16,14 +16,14 @@ jobs: build-and-deploy-docs: name: Build and Deploy Documentation if: github.repository_owner == 'spring-projects' - runs-on: ubuntu-latest + runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - name: Check Out uses: actions/checkout@v4 with: fetch-depth: 0 - name: Fetch Main Branch - run: git fetch origin main:main + run: git fetch origin ${{ github.event.repository.default_branch }}:main - name: Set Up Node uses: actions/setup-node@v4 with: @@ -41,10 +41,15 @@ jobs: env: ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + COMMERCIAL_REPO_USERNAME: ${{ secrets.COMMERCIAL_ARTIFACTORY_RO_USERNAME }} + COMMERCIAL_REPO_PASSWORD: ${{ secrets.COMMERCIAL_ARTIFACTORY_RO_PASSWORD }} + COMMERCIAL_SNAPSHOT_REPO_URL: ${{ vars.COMMERCIAL_SNAPSHOT_REPO_URL }} + COMMERCIAL_RELEASE_REPO_URL: ${{ vars.COMMERCIAL_RELEASE_REPO_URL }} BUILD_REFNAME: ${{ github.event.inputs.build-refname }} BUILD_VERSION: ${{ github.event.inputs.build-version }} run: node run.js --no-checkout - - name: Sync Documentation + - name: Sync OSS Documentation + if: ${{ !vars.COMMERCIAL }} uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.20 with: docs-username: ${{ secrets.DOCS_USERNAME }} @@ -55,13 +60,26 @@ jobs: env: BUILD_REFNAME: ${{ github.event.inputs.build-refname }} BUILD_VERSION: ${{ github.event.inputs.build-version }} - - name: Bust Cloudflare Cache + - name: Bust OSS Cloudflare Cache + if: ${{ !vars.COMMERCIAL }} uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.20 with: context-root: spring-boot context-path: / cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} + - name: Authenticate for commercial distribution + if: ${{ vars.COMMERCIAL }} + uses: 'google-github-actions/auth@v2.1.0' + with: + credentials_json: '${{ secrets.COMMERCIAL_DOCS_GCP_BUCKET_JSON }}' + - name: Sync commercial Documentation + if: ${{ vars.COMMERCIAL }} + uses: 'google-github-actions/upload-cloud-storage@v2.1.0' + with: + path: 'build/site' + destination: '${{ vars.COMMERCIAL_DOCS_HOST }}/spring-boot' + parent: false - name: Send Notification if: failure() uses: ./.github/actions/send-notification diff --git a/antora-commercial-playbook.yml b/antora-commercial-playbook.yml new file mode 100644 index 00000000000..c8f09b932d4 --- /dev/null +++ b/antora-commercial-playbook.yml @@ -0,0 +1,63 @@ +antora: + extensions: + - require: '@antora/atlas-extension' + - require: '@springio/antora-extensions/latest-version-extension' + - require: '@springio/antora-extensions/override-navigation-builder-extension' + - require: '@springio/antora-extensions/partial-build-extension' + - require: '@springio/antora-extensions/publish-docsearch-config-extension' + - require: '@springio/antora-extensions/set-algolia-env-extension' + - require: '@springio/antora-extensions/static-page-extension' + - require: '@springio/antora-xref-extension' + - require: '@springio/antora-zip-contents-collector-extension' + version_file: gradle.properties + on_missing_snapshot_zip: drop_content + username: '${env.COMMERCIAL_REPO_USERNAME}' + password: '${env.COMMERCIAL_REPO_PASSWORD}' + locations: + - url: ${env.COMMERCIAL_SNAPSHOT_REPO_URL}/org/springframework/boot/spring-boot-docs/${version}/spring-boot-docs-${version}-${name}-${classifier}.zip + for-version-type: [snapshot] + - url: ${env.COMMERCIAL_RELEASE_REPO_URL}/org/springframework/boot/spring-boot-docs/${version}/spring-boot-docs-${version}-${name}-${classifier}.zip + for-version-type: [release] + # The root component extension must be last! + - require: '@springio/antora-extensions/root-component-extension' + root_component_name: boot +site: + title: Spring Boot + url: https://docs.spring.vmware.com/spring-boot + robots: allow +content: + sources: + - url: . + branches: + - '3.3.x' + tags: + - '3.3.{14..100}*' + start_paths: + - spring-boot-project/spring-boot-docs/src/docs/antora + - spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/antora + - spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/antora + - spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/antora + version: unspecified + edit_url: ~ +asciidoc: + sourcemap: true + attributes: + chomp: all + hide-uri-scheme: '@' + javadoc-location: xref:api:java/ + page-pagination: '' + page-stackoverflow-url: https://stackoverflow.com/tags/spring-boot + tabs-sync-option: '@' + extensions: + - '@asciidoctor/tabs' + - '@springio/asciidoctor-extensions' + - '@springio/asciidoctor-extensions/configuration-properties-extension' + - '@springio/asciidoctor-extensions/javadoc-extension' + - '@springio/asciidoctor-extensions/section-ids-extension' +urls: + latest_version_segment: '' + latest_version_segment_strategy: redirect:to + redirect_facility: httpd +runtime: + log: + failure_level: warn diff --git a/run.js b/run.js index d2c5d3ed7d4..aec8fd63548 100644 --- a/run.js +++ b/run.js @@ -35,7 +35,8 @@ function run(skip) { const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')) const uiBundleUrl = packageJson.config['ui-bundle-url']; - const command = `npx antora antora-playbook.yml --stacktrace --ui-bundle-url ${uiBundleUrl}` + const playbook = (process.env.COMMERCIAL_RELEASE_REPO_URL) ? 'antora-commercial-playbook.yml' : 'antora-playbook.yml' + const command = `npx antora ${playbook} --stacktrace --ui-bundle-url ${uiBundleUrl}` if (uiBundleUrl.includes('/latest/')) { console.log('Refusing to run Antora with development build of UI') console.log(`$ ${command}`)