Use pacakge.json from 'main'

Update the docs build to use the `package.json` file from the
`main` branch.

See gh-40072
This commit is contained in:
Phillip Webb 2024-03-29 10:27:30 -07:00
parent ec43c92150
commit 669a1eecd5
6 changed files with 58 additions and 3323 deletions

View File

@ -22,13 +22,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch Main Branch
run: git fetch origin main:main
- name: Set Up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Set Up NPM
run: npm ci
- name: Run Antora
- name: Install and Run Antora
env:
ALGOLIA_APP_ID: 244V8V9FGG
ALGOLIA_API_KEY: 82c7ead946afbac3cf98c32446154691
@ -37,7 +37,7 @@ jobs:
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
REFERENCE: ${{ github.event.inputs.build-refname }}
BUILD_VERSION: ${{ github.event.inputs.build-version }}
run: npx antora antora-playbook.yml --stacktrace
run: node run.js
- name: Sync Documentation
uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.15
with:

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
node_modules
.vscode
build
package.json
package-lock.json

View File

@ -8,8 +8,8 @@ antora:
- require: '@springio/antora-xref-extension'
- require: '@springio/antora-zip-contents-collector-extension'
version_file: gradle.properties
username: ${env.ARTIFACTORY_USERNAME}"
password: ${env.ARTIFACTORY_PASSWORD}"
username: '${env.ARTIFACTORY_USERNAME}'
password: '${env.ARTIFACTORY_PASSWORD}'
locations:
- url: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-docs/${version}/spring-boot-docs-${version}-${name}-${classifier}.zip
for-version-type: [snapshot]
@ -64,6 +64,3 @@ urls:
runtime:
log:
failure_level: warn
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.11/ui-bundle.zip

3299
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
{
"scripts": {
"antora": "node npm/antora.js"
},
"devDependencies": {
"@antora/cli": "3.2.0-alpha.4",
"@antora/site-generator": "3.2.0-alpha.4",
"@antora/atlas-extension": "1.0.0-alpha.2",
"@springio/antora-extensions": "1.8.2",
"@springio/antora-xref-extension": "1.0.0-alpha.3",
"@springio/antora-zip-contents-collector-extension": "1.0.0-alpha.2",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/asciidoctor-extensions": "1.0.0-alpha.10"
}
}

50
run.js Normal file
View File

@ -0,0 +1,50 @@
;(function () {
'use strict'
const childProcess = require('child_process')
const fs = require('fs');
async function main() {
try {
checkout(process.argv.includes('--no-checkout'))
install(process.argv.includes('--no-install'))
run(process.argv.includes('--no-run'))
} catch (error) {
console.log("Unexpected error")
process.exitCode = (error.exitCode) ? error.exitCode : 1
}
}
function checkout(skip) {
if (skip) return
console.log('Checking out Antora package.json files from `main`')
const packageJson = childProcess.execSync('git show main:antora/package.json', {env: process.env})
const packageLockJson = childProcess.execSync('git show main:antora/package-lock.json', {env: process.env})
fs.writeFileSync('package.json', packageJson)
fs.writeFileSync('package-lock.json', packageLockJson)
}
function install(skip) {
if (skip) return
console.log('Installing modules')
childProcess.execSync('npm ci --silent --no-progress', {stdio: 'inherit', env: process.env})
}
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}`
if (uiBundleUrl.includes('/latest/')) {
console.log('Refusing to run Antora with development build of UI')
console.log(`$ ${command}`)
process.exitCode = 1
return
}
console.log((!skip) ? 'Running Antora' : 'Use the following command to run Antora')
console.log(`$ ${command}`)
if (!skip) childProcess.execSync(command, {stdio: 'inherit', env: process.env})
}
main()
})()