From 7cea7b49aafd677a96857eeac8365a44948c3afd Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Thu, 1 Sep 2022 14:03:36 -0600 Subject: [PATCH] set up CI workflow to deploy docs --- .github/actions/publish-docs.sh | 18 ++++++++++++++++++ .github/workflows/deploy-docs.yml | 28 ++++++++++++++++++++++++++++ .sdkmanrc | 6 ++++++ build.gradle | 2 +- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/actions/publish-docs.sh create mode 100644 .github/workflows/deploy-docs.yml create mode 100644 .sdkmanrc diff --git a/.github/actions/publish-docs.sh b/.github/actions/publish-docs.sh new file mode 100644 index 0000000000..ce60e1793f --- /dev/null +++ b/.github/actions/publish-docs.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +HOST="$1" +HOST_PATH="$2" +SSH_PRIVATE_KEY="$3" +SSH_KNOWN_HOST="$4" +SSH_PRIVATE_KEY_PATH="$HOME/.ssh-ci/${GITHUB_REPOSITORY:-publish-docs}" + +if [ "$#" -ne 4 ]; then + echo -e "not enough arguments USAGE:\n\n$0 \$HOST \$HOST_PATH \$SSH_PRIVATE_KEY \$SSH_KNOWN_HOSTS\n\n" >&2 + exit 1 +fi + +install -m 600 -D /dev/null "$SSH_PRIVATE_KEY_PATH" +echo "$SSH_PRIVATE_KEY" > "$SSH_PRIVATE_KEY_PATH" +echo "$SSH_KNOWN_HOST" > ~/.ssh/known_hosts +rsync --delete -avze "ssh -i $SSH_PRIVATE_KEY_PATH" docs/build/site/ "$HOST:$HOST_PATH" +rm -f "$SSH_PRIVATE_KEY_PATH" diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000000..5707ae50a9 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,28 @@ +name: Deploy Docs +on: + workflow_dispatch: +permissions: read-all +jobs: + build: + runs-on: ubuntu-latest + #if: github.repository_owner == 'spring-projects' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 5 + - name: Set Up Gradle + uses: spring-io/spring-gradle-build-action@v1 + with: + java-version: '17' + distribution: temurin + - name: Scrub Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f /home/runner/.gradle/caches/modules-2/modules-2.lock + rm -f /home/runner/.gradle/caches/modules-2/gc.properties + - name: Run Antora + run: ./gradlew antora + - name: Publish Docs + run: ${GITHUB_WORKSPACE}/.github/actions/publish-docs.sh "${{ secrets.DOCS_USERNAME }}@${{ secrets.DOCS_HOST }}" /opt/www/domains/spring.io/docs/htdocs/spring-security/reference/ "${{ secrets.DOCS_SSH_KEY }}" "${{ secrets.DOCS_SSH_HOST_KEY }}" diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 0000000000..64345a4be3 --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1,6 @@ +# Use sdkman to run "sdk env" to initialize with correct JDK version +# Enable auto-env through the sdkman_auto_env config +# See https://sdkman.io/usage#config +# A summary is to add the following to ~/.sdkman/etc/config +# sdkman_auto_env=true +java=17.0.3-tem diff --git a/build.gradle b/build.gradle index e008a04c6a..b854b68865 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ node { antora { antoraVersion = "3.1.0" - arguments = ["--fetch", "--stacktrace"] + arguments = ["--clean", "--fetch", "--stacktrace"] } tasks.antora {