From 95c03db739c1d6d894c3c613c7be86a341003a37 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Thu, 22 Jun 2023 13:49:15 -0500 Subject: [PATCH] Update Documentation Actions Issue gh-2327 --- .github/actions/algolia-config.json | 20 ------------ .github/actions/algolia-deploy.sh | 20 ------------ .github/actions/algolia-docsearch-scraper.sh | 21 ------------- .github/actions/dispatch.sh | 5 --- .github/workflows/algolia-index.yml | 16 ---------- .github/workflows/antora-generate.yml | 30 ------------------ .github/workflows/deploy-docs.yml | 31 ++++++++++++++++++ .github/workflows/deploy-reference.yml | 33 -------------------- 8 files changed, 31 insertions(+), 145 deletions(-) delete mode 100644 .github/actions/algolia-config.json delete mode 100755 .github/actions/algolia-deploy.sh delete mode 100755 .github/actions/algolia-docsearch-scraper.sh delete mode 100755 .github/actions/dispatch.sh delete mode 100644 .github/workflows/algolia-index.yml delete mode 100644 .github/workflows/antora-generate.yml create mode 100644 .github/workflows/deploy-docs.yml delete mode 100644 .github/workflows/deploy-reference.yml diff --git a/.github/actions/algolia-config.json b/.github/actions/algolia-config.json deleted file mode 100644 index 6fdbf5b3..00000000 --- a/.github/actions/algolia-config.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "index_name": "session-docs", - "start_urls": [ - "https://docs.spring.io/spring-session/reference/" - ], - "selectors": { - "lvl0": { - "selector": "//nav[@class='crumbs']//li[@class='crumb'][last()-1]", - "type": "xpath", - "global": true, - "default_value": "Home" - }, - "lvl1": ".doc h1", - "lvl2": ".doc h2", - "lvl3": ".doc h3", - "lvl4": ".doc h4", - "text": ".doc p, .doc td.content, .doc th.tableblock" - } -} - diff --git a/.github/actions/algolia-deploy.sh b/.github/actions/algolia-deploy.sh deleted file mode 100755 index 35021f18..00000000 --- a/.github/actions/algolia-deploy.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -HOST="$1" -HOST_PATH="$2" -SSH_PRIVATE_KEY="$3" -SSH_KNOWN_HOST="$4" - - -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 - -# Use a non-default path to avoid overriding when testing locally -SSH_PRIVATE_KEY_PATH=~/.ssh/github-actions-docs -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" spring-session-docs/build/site/ "$HOST:$HOST_PATH" -rm -f "$SSH_PRIVATE_KEY_PATH" diff --git a/.github/actions/algolia-docsearch-scraper.sh b/.github/actions/algolia-docsearch-scraper.sh deleted file mode 100755 index 2bb9ce17..00000000 --- a/.github/actions/algolia-docsearch-scraper.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -### -# Docs -# config.json https://docsearch.algolia.com/docs/config-file -# Run the crawler https://docsearch.algolia.com/docs/run-your-own/#run-the-crawl-from-the-docker-image - -### USAGE -if [ "$#" -ne 3 ]; then - echo -e "not enough arguments USAGE:\n\n$0 \$ALGOLIA_APPLICATION_ID \$ALGOLIA_API_KEY \$CONFIG_FILE\n\n" >&2 - exit 1 -fi - -# Script Parameters -APPLICATION_ID=$1 -API_KEY=$2 -CONFIG_FILE=$3 - -#### Script -script_dir=$(dirname $0) -docker run -e "APPLICATION_ID=$APPLICATION_ID" -e "API_KEY=$API_KEY" -e "CONFIG=$(cat $CONFIG_FILE | jq -r tostring)" algolia/docsearch-scraper diff --git a/.github/actions/dispatch.sh b/.github/actions/dispatch.sh deleted file mode 100755 index 955e9cbb..00000000 --- a/.github/actions/dispatch.sh +++ /dev/null @@ -1,5 +0,0 @@ -REPOSITORY_REF="$1" -TOKEN="$2" - -curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${TOKEN}" --request POST --data '{"event_type": "request-build-reference"}' https://api.github.com/repos/${REPOSITORY_REF}/dispatches -echo "Requested Build for $REPOSITORY_REF" diff --git a/.github/workflows/algolia-index.yml b/.github/workflows/algolia-index.yml deleted file mode 100644 index dfc2295a..00000000 --- a/.github/workflows/algolia-index.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Update Algolia Index - -on: - schedule: - - cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: # Manual trigger - -jobs: - update: - name: Update Algolia Index - runs-on: ubuntu-latest - steps: - - name: Checkout Source - uses: actions/checkout@v2 - - name: Update Index - run: ${GITHUB_WORKSPACE}/.github/actions/algolia-docsearch-scraper.sh "${{ secrets.ALGOLIA_APPLICATION_ID }}" "${{ secrets.ALGOLIA_WRITE_API_KEY }}" "${GITHUB_WORKSPACE}/.github/actions/algolia-config.json" diff --git a/.github/workflows/antora-generate.yml b/.github/workflows/antora-generate.yml deleted file mode 100644 index 3612b901..00000000 --- a/.github/workflows/antora-generate.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Generate Antora Files and Request Build - -on: - push: - branches-ignore: - - 'gh-pages' - -env: - GH_ACTIONS_REPO_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Source - uses: actions/checkout@v2 - - name: Generate antora.yml - run: ./gradlew :spring-session-docs:generateAntora - - name: Extract Branch Name - id: extract_branch_name - run: echo "##[set-output name=generated_branch_name;]$(echo ${GITHUB_REPOSITORY}/${GITHUB_REF##*/})" - - name: Push generated antora files to the spring-generated-docs - uses: JamesIves/github-pages-deploy-action@4.1.4 - with: - branch: ${{ steps.extract_branch_name.outputs.generated_branch_name }} # The branch the action should deploy to. - folder: "spring-session-docs/build/generateAntora" # The folder the action should deploy. - repository-name: "spring-io/spring-generated-docs" - token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} - - name: Dispatch Build Request - run: ${GITHUB_WORKSPACE}/.github/actions/dispatch.sh 'spring-projects/spring-session' "$GH_ACTIONS_REPO_TOKEN" diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..b2d407b9 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,31 @@ +name: Deploy Docs +on: + push: + branches-ignore: [ gh-pages ] + tags: '**' + repository_dispatch: + types: request-build-reference # legacy + #schedule: + #- cron: '0 10 * * *' # Once per day at 10am UTC + workflow_dispatch: +permissions: read-all +jobs: + build: + runs-on: ubuntu-latest + if: github.repository_owner == 'spring-projects' + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: docs-build + fetch-depth: 1 + - name: Dispatch (partial build) + if: github.ref_type == 'branch' + env: + GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} + run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} + - name: Dispatch (full build) + if: github.ref_type == 'tag' + env: + GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} + run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) diff --git a/.github/workflows/deploy-reference.yml b/.github/workflows/deploy-reference.yml deleted file mode 100644 index 757d2f51..00000000 --- a/.github/workflows/deploy-reference.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Build & Deploy Reference - -on: - repository_dispatch: - types: request-build-reference - schedule: - - cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: # Manual trigger - -jobs: - deploy: - name: deploy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b - - name: Build with Gradle - run: ./gradlew :spring-session-docs:antora --stacktrace - - name: Cleanup 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 ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties - - name: Deploy - run: ${GITHUB_WORKSPACE}/.github/actions/algolia-deploy.sh "${{ secrets.DOCS_USERNAME }}@${{ secrets.DOCS_HOST }}" "/opt/www/domains/spring.io/docs/htdocs/spring-session/reference/" "${{ secrets.DOCS_SSH_KEY }}" "${{ secrets.DOCS_SSH_HOST_KEY }}"