diff --git a/.github/actions/build-and-publish-pr-preview/README.md b/.github/actions/build-and-publish-pr-preview/README.md index 3c4af3053..011c22559 100644 --- a/.github/actions/build-and-publish-pr-preview/README.md +++ b/.github/actions/build-and-publish-pr-preview/README.md @@ -1,6 +1,8 @@ # build and publish pr preview -**WARN**: Only work on Ubuntu runners +**WARN**: Only work +- with Pull Requests +- on Ubuntu runners Manage the surge preview deployment. In particular, teardown the surge deployment when closing the Pull Request. diff --git a/.github/actions/build-and-publish-pr-preview/action.yml b/.github/actions/build-and-publish-pr-preview/action.yml index a572c66e3..d05edf7e1 100644 --- a/.github/actions/build-and-publish-pr-preview/action.yml +++ b/.github/actions/build-and-publish-pr-preview/action.yml @@ -48,7 +48,7 @@ runs: - name: Build Setup uses: ./.github/actions/build-setup if: github.event.action != 'closed' - - name: Build Site without error check + - name: Build Site for a single component if: github.event.action != 'closed' && inputs.component-name != '' shell: bash # '>' Replace newlines with spaces (folded) @@ -57,12 +57,13 @@ runs: ./build-preview.bash --branch "${{ github.head_ref }}" --component "${{inputs.component-name}}" + --component-repo-url "${{github.event.pull_request.head.repo.clone_url}}" --fail-on-warning "${{inputs.fail-on-warning}}" --fetch-sources true --ignore-errors "${{inputs.ignore-errors}}" --pr "${{ github.event.pull_request.number }}" --site-url "${{ steps.surge-preview-tools.outputs.preview-url }}" - - name: Build Site + - name: Build Site with custom build-preview command if: github.event.action != 'closed' && inputs.component-name == '' shell: bash # '>' Replace newlines with spaces (folded) diff --git a/.github/actions/build-pr-site/action.yml b/.github/actions/build-pr-site/action.yml index 8d9e9e3ca..a373157e7 100644 --- a/.github/actions/build-pr-site/action.yml +++ b/.github/actions/build-pr-site/action.yml @@ -3,8 +3,12 @@ description: 'Build site from a PR to check if all xref references are valid' inputs: build-preview-command: - description: 'The documentation `build-preview` command to build the preview' - required: true + description: 'The documentation `build-preview` command to build the preview and validate references. Mandatory when `component-name` is not set. Otherwise, ignored.' + required: false + component-name: + description: 'The name of the component to build. If set, the build-preview-command input is ignored' + required: false + default: '' # needed by content repository (default master) and here (computed automagically) doc-site-branch: description: 'The branch of the `bonita-documentation-site` used to build the site preview' @@ -30,7 +34,21 @@ runs: - name: Install antora dependencies for xref validation shell: bash run: npm install --save-dev antora@3.2.0-alpha.4 - - name: Build Site + - name: Build Site for a single component + if: inputs.component-name != '' + shell: bash + # '>' Replace newlines with spaces (folded) + # '-' No newline at end (strip) + run: >- + ./build-preview.bash + --branch "${{ github.head_ref }}" + --component "${{inputs.component-name}}" + --component-repo-url "${{github.event.pull_request.head.repo.clone_url}}" + --fail-on-warning "${{inputs.fail-on-warning}}" + --fetch-sources true + --pr "${{ github.event.pull_request.number }}" + - name: Build Site with custom build-preview command + if: inputs.component-name == '' shell: bash # '>' Replace newlines with spaces (folded) # '-' No newline at end (strip) diff --git a/build-preview.bash b/build-preview.bash index 41e22cb6f..ee8f50af6 100755 --- a/build-preview.bash +++ b/build-preview.bash @@ -26,6 +26,7 @@ function usage() { echo "Antora configuration" echo " --branch Name of the branch when keeping a single branch per component" echo " --component Name of the component when keeping a single branch per component" + echo " --component-repo-url Only relevant when keeping a single branch per component. Override the configured git repository URL for the provided component" echo " --component-with-branches
Components and branches when using 'Multiple Repositories'." echo " Pass one argument per component. For instance, --component-with-branches bcd:3.4 --component-with-branches bonita:7.11,2021.1" echo " --default-ui-bundle If set, use the Antora Default UI. If set to 'snapshot', fetch the bundle instead of retrieving it from the cache. Defaults to 'false'" diff --git a/lib/antora/log-aggregated-component-versions-extension.js b/lib/antora/log-aggregated-component-versions-extension.js index 9bd868b9f..7ebf4d120 100644 --- a/lib/antora/log-aggregated-component-versions-extension.js +++ b/lib/antora/log-aggregated-component-versions-extension.js @@ -9,7 +9,7 @@ module.exports.register = function () { const logger = this.getLogger('bonita-log-aggregated-component'); this.once('contentAggregated', ({ contentAggregate }) => { - logger.info('Discovered the following component versions') + logger.info('Start discovering component versions') contentAggregate.forEach((bucket) => { logger.info(`name: ${bucket.name}, version: ${bucket.version}, files: ${bucket.files.length}`) if (logger.isLevelEnabled('debug')) { @@ -17,5 +17,6 @@ module.exports.register = function () { logger.debug('sources: %o', sources); } }) + logger.info('Done discovery of component versions') }) } diff --git a/scripts/generate-content-for-preview-antora-playbook.js b/scripts/generate-content-for-preview-antora-playbook.js index 8b1a1fc12..bba160f69 100644 --- a/scripts/generate-content-for-preview-antora-playbook.js +++ b/scripts/generate-content-for-preview-antora-playbook.js @@ -138,7 +138,15 @@ else { // override the sources: only the single branch of the single component const repoUrl = getRepoUrl(componentName); - doc.content.sources = [{ url: repoUrl, branches: [branchName] }]; + console.info(`Configured repo URL for the component: ${repoUrl}`); + // if provided a specific repository, use it. Calling getRepoUrl validates that the component is known + const repoUrlArg = getArgument(argv, 'component-repo-url', false); + if (repoUrlArg) { + console.info(`--> Overriding repo URL with the provided argument: ${repoUrlArg}`); + doc.content.sources = [{ url: repoUrlArg, branches: [branchName] }]; + } else { + doc.content.sources = [{ url: repoUrl, branches: [branchName] }]; + } const titlePreviewPart = prNumber ? `PR #${prNumber}` : `branch '${branchName}'`; doc.site.title = siteTitle || `Preview ${componentName} ${titlePreviewPart}`;