From bd4bd917454bfa52ab341a8f8d20ca4dffceec0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20K=C3=B6ninger?= Date: Fri, 13 Dec 2024 13:18:31 +0100 Subject: [PATCH] fix(docs): add redirect function for /current path (#3922) --- .../workflows/release-to-maven-central.yml | 25 ++-- spring-boot-admin-docs/src/site/.gitignore | 1 + .../src/site/current/404.template.html | 111 ++++++++++++++++++ spring-boot-admin-docs/src/site/package.json | 4 +- 4 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 spring-boot-admin-docs/src/site/current/404.template.html diff --git a/.github/workflows/release-to-maven-central.yml b/.github/workflows/release-to-maven-central.yml index 98614407253..d3e3ade3ea3 100644 --- a/.github/workflows/release-to-maven-central.yml +++ b/.github/workflows/release-to-maven-central.yml @@ -68,22 +68,31 @@ jobs: MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - - name: Deploy Asciidoc docs output to GitHub Pages + - 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 # The branch the action should deploy to. - folder: spring-boot-admin-docs/target/generated-docs # The folder the action should deploy. + branch: gh-pages + folder: spring-boot-admin-docs/target/generated-docs target-folder: ${{ github.event.inputs.releaseversion }} - clean: true # Automatically remove deleted files from the deploy branch + clean: true - - name: Deploy Asciidoc docs output to GitHub Pages + - 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 # The branch the action should deploy to. - folder: spring-boot-admin-docs/target/generated-docs/current # The folder the action should deploy. + branch: gh-pages + folder: spring-boot-admin-docs/target/generated-docs/current target-folder: /current - clean: true # Automatically remove deleted files from the deploy branch + 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 publish-github-release: needs: publish-central-and-pages diff --git a/spring-boot-admin-docs/src/site/.gitignore b/spring-boot-admin-docs/src/site/.gitignore index e3383dad8fc..904f63bb03c 100644 --- a/spring-boot-admin-docs/src/site/.gitignore +++ b/spring-boot-admin-docs/src/site/.gitignore @@ -18,3 +18,4 @@ npm-debug.log* current/index.html +current/404.html diff --git a/spring-boot-admin-docs/src/site/current/404.template.html b/spring-boot-admin-docs/src/site/current/404.template.html new file mode 100644 index 00000000000..ed2e0774801 --- /dev/null +++ b/spring-boot-admin-docs/src/site/current/404.template.html @@ -0,0 +1,111 @@ + + + + + Page not found · GitHub Pages + + + + + +
+ +

404

+

There isn't a GitHub Pages site here.

+ +

+ Did you mean to visit docs.spring-boot-admin.com? + Please note that this site belongs to a GitHub user and is + not an official GitHub site. +

+ + +
+ + diff --git a/spring-boot-admin-docs/src/site/package.json b/spring-boot-admin-docs/src/site/package.json index 43de20856a2..463c4e76781 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", + "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": "docusaurus build", - "build:prod": "npm run build && npm run build:current-version-redirect && cp ./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",