From fe252f5057377a1cdf8ef0efdee0a707be646590 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Mon, 21 Nov 2022 17:26:21 -0700 Subject: [PATCH 1/2] sync docs build; upgrade Antora and Antora Collector to latest alpha --- .github/actions/dispatch.sh | 5 --- .github/workflows/antora-generate.yml | 41 --------------------- .github/workflows/deploy-docs.yml | 31 ++++++++++++++++ docs/antora-linked-worktree-patch.js | 53 --------------------------- docs/local-antora-playbook.yml | 1 - docs/spring-security-docs.gradle | 4 +- 6 files changed, 33 insertions(+), 102 deletions(-) delete mode 100755 .github/actions/dispatch.sh delete mode 100644 .github/workflows/antora-generate.yml create mode 100644 .github/workflows/deploy-docs.yml delete mode 100644 docs/antora-linked-worktree-patch.js diff --git a/.github/actions/dispatch.sh b/.github/actions/dispatch.sh deleted file mode 100755 index 955e9cbbee..0000000000 --- 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/antora-generate.yml b/.github/workflows/antora-generate.yml deleted file mode 100644 index 3f29ae9c9b..0000000000 --- a/.github/workflows/antora-generate.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Generate Antora Files and Request Build - -on: - workflow_dispatch: - push: - branches-ignore: - - 'gh-pages' - tags: '**' - -env: - GH_ACTIONS_REPO_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - if: ${{ github.repository == 'spring-projects/spring-security' }} - steps: - - name: Checkout Source - uses: actions/checkout@v2 - - name: Set up gradle - uses: spring-io/spring-gradle-build-action@v1 - with: - java-version: '11' - distribution: 'adopt' - - name: Generate antora.yml - run: ./gradlew :spring-security-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: "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-security' "$GH_ACTIONS_REPO_TOKEN" diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000000..32b9f5056d --- /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/docs/antora-linked-worktree-patch.js b/docs/antora-linked-worktree-patch.js deleted file mode 100644 index 43e4145211..0000000000 --- a/docs/antora-linked-worktree-patch.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict' - -/* Copyright (c) 2002-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const { promises: fsp } = require('fs') -const ospath = require('path') - -/** - * Rewrites local content sources to support the use of linked worktrees. - * - * @author Dan Allen - */ -module.exports.register = function () { - this.once('playbookBuilt', async ({ playbook }) => { - const expandPath = this.require('@antora/expand-path-helper') - for (const contentSource of playbook.content.sources) { - const { url, branches } = contentSource - if (url.charAt() !== '.') continue - const absdir = expandPath(url, { dot: playbook.dir }) - const gitfile = ospath.join(absdir, '.git') - if (await fsp.stat(gitfile).then((stat) => !stat.isDirectory(), () => false)) { - const worktreeGitdir = await fsp.readFile(gitfile, 'utf8') - .then((contents) => contents.trimRight().substr(8)) - const worktreeBranch = await fsp.readFile(ospath.join(worktreeGitdir, 'HEAD'), 'utf8') - .then((contents) => contents.trimRight().replace(/^ref: (?:refs\/heads\/)?/, '')) - const reldir = ospath.relative( - playbook.dir, - await fsp.readFile(ospath.join(worktreeGitdir, 'commondir'), 'utf8') - .then((contents) => { - const gitdir = ospath.join(worktreeGitdir, contents.trimRight()) - return ospath.basename(gitdir) === '.git' ? ospath.dirname(gitdir) : gitdir - }) - ) - contentSource.url = reldir ? `.${ospath.sep}${reldir}` : '.' - if (!branches) continue - contentSource.branches = (branches.constructor === Array ? branches : [branches]) - .map((pattern) => pattern.replaceAll('HEAD', worktreeBranch)) - } - } - }) -} diff --git a/docs/local-antora-playbook.yml b/docs/local-antora-playbook.yml index e6245c7a7c..b58142e2eb 100644 --- a/docs/local-antora-playbook.yml +++ b/docs/local-antora-playbook.yml @@ -1,7 +1,6 @@ # The purpose of this Antora playbook is to generate a preview of the docs in the current branch. antora: extensions: - - ./antora-linked-worktree-patch.js - '@antora/collector-extension' site: title: Spring Security diff --git a/docs/spring-security-docs.gradle b/docs/spring-security-docs.gradle index 708a22542f..2ec3e11365 100644 --- a/docs/spring-security-docs.gradle +++ b/docs/spring-security-docs.gradle @@ -6,7 +6,7 @@ apply plugin: 'io.spring.convention.docs' apply plugin: 'java' antora { - version = '~3.1' + version = '3.2.0-alpha.2' playbook = file('local-antora-playbook.yml') options = ['--clean', '--stacktrace'] environment = [ @@ -15,7 +15,7 @@ antora { 'ALGOLIA_INDEX_NAME': 'security-docs' ] dependencies = [ - '@antora/collector-extension': '1.0.0-alpha.2' + '@antora/collector-extension': '1.0.0-alpha.3' ] } From 3f2bade4f13fa6967d4f54b4b40489faf0d04e4d Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Mon, 21 Nov 2022 17:49:18 -0700 Subject: [PATCH 2/2] sync and refactor docs build - upgrade Antora to 3.2.0-alpha.2 - remove Antora patch to support linked worktrees - upgrade Antora Collector to latest alpha - remove dispatch.sh script (handled by gh run workflow) - consistently use gh run workflow to trigger workflows - remove step to publish generated docs (no longer in use) --- .github/actions/dispatch.sh | 5 ---- .github/workflows/antora-generate.yml | 41 --------------------------- .github/workflows/deploy-docs.yml | 3 ++ 3 files changed, 3 insertions(+), 46 deletions(-) delete mode 100755 .github/actions/dispatch.sh delete mode 100644 .github/workflows/antora-generate.yml diff --git a/.github/actions/dispatch.sh b/.github/actions/dispatch.sh deleted file mode 100755 index 955e9cbbee..0000000000 --- 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/antora-generate.yml b/.github/workflows/antora-generate.yml deleted file mode 100644 index 69b7258443..0000000000 --- a/.github/workflows/antora-generate.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Generate Antora Files and Request Build - -on: - workflow_dispatch: - push: - branches-ignore: - - 'gh-pages' - tags: '**' - -env: - GH_ACTIONS_REPO_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - if: ${{ github.repository == 'spring-projects/spring-security' }} - steps: - - name: Checkout Source - uses: actions/checkout@v2 - - name: Set up gradle - uses: spring-io/spring-gradle-build-action@v1 - with: - java-version: '17' - distribution: 'temurin' - - name: Generate antora.yml - run: ./gradlew :spring-security-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: "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-security' "$GH_ACTIONS_REPO_TOKEN" diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 6279ea3a22..32b9f5056d 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,5 +1,8 @@ name: Deploy Docs on: + push: + branches-ignore: [ gh-pages ] + tags: '**' repository_dispatch: types: request-build-reference # legacy schedule: