From 0a048f5c98d771330c950250e15dd9c4d9ee0dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20K=C3=B6ninger?= Date: Mon, 10 Feb 2025 11:08:05 +0100 Subject: [PATCH] fix: deployment of documentation (#4023) --- .github/workflows/deploy-documentation.yml | 76 ++++++++++++++++++++ spring-boot-admin-docs/src/site/package.json | 4 +- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy-documentation.yml diff --git a/.github/workflows/deploy-documentation.yml b/.github/workflows/deploy-documentation.yml new file mode 100644 index 00000000000..815be345dfb --- /dev/null +++ b/.github/workflows/deploy-documentation.yml @@ -0,0 +1,76 @@ +name: 📖 Deploy Documentation + +on: + workflow_dispatch: + inputs: + releaseversion: + description: 'Release version' + required: true + default: '3.0.0' + copyDocsToCurrent: + description: "Should the docs be published at https://docs.spring-boot-admin.com? Otherwise they will be accessible by version number only." + required: true + type: boolean + default: false +env: + VERSION: ${{ github.event.inputs.releaseversion }} + +jobs: + deploy-documentation: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Set projects Maven version to GitHub Action GUI set version + run: mvn versions:set "-DnewVersion=${{ github.event.inputs.releaseversion }}" --no-transfer-progress + + - name: Build with Maven + run: mvn -B --no-transfer-progress install -DskipTests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Deploy documentation to GitHub Pages for version ${{ github.event.inputs.releaseversion }} + uses: JamesIves/github-pages-deploy-action@v4.7.2 + with: + branch: gh-pages + folder: spring-boot-admin-docs/target/generated-docs + target-folder: ${{ github.event.inputs.releaseversion }} + clean: true + + - name: Deploy redirect for /current to /${{ github.event.inputs.releaseversion }} + uses: JamesIves/github-pages-deploy-action@v4.7.2 + if: github.event.inputs.copyDocsToCurrent == 'true' + with: + branch: gh-pages + folder: spring-boot-admin-docs/target/generated-docs/current + target-folder: /current + clean: true + + - name: Deploy deeplink redirect for /current/* to /${{ github.event.inputs.releaseversion }}/* + uses: JamesIves/github-pages-deploy-action@v4.7.2 + if: github.event.inputs.copyDocsToCurrent == 'true' + with: + branch: gh-pages + folder: spring-boot-admin-docs/target/generated-docs/current + target-folder: / + clean: false diff --git a/spring-boot-admin-docs/src/site/package.json b/spring-boot-admin-docs/src/site/package.json index 0b457eacc27..95badc2052f 100644 --- a/spring-boot-admin-docs/src/site/package.json +++ b/spring-boot-admin-docs/src/site/package.json @@ -5,9 +5,9 @@ "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start", - "build:current-version-redirect": "sed \"s/@@VERSION@@/$VERSION/g\" current/index.template.html > current/index.html && sed \"s/@@VERSION@@/$VERSION/g\" current/404.template.html > current/404.html", + "build:current-version-redirect": "mkdir -p build/current/ && sed \"s/@@VERSION@@/$VERSION/g\" current/index.template.html > build/current/index.html && sed \"s/@@VERSION@@/$VERSION/g\" current/404.template.html > build/current/404.html", "build": "docusaurus build", - "build:prod": "npm run build && npm run build:current-version-redirect && rm -rf ../../target/generated-docs && mv ./build ../../target/generated-docs" + "build:prod": "npm run build && npm run build:current-version-redirect && mv ./build ../../target/generated-docs" }, "dependencies": { "@docusaurus/core": "^3.6.3",