Skip to content

Generate HTML from dev #121

Generate HTML from dev

Generate HTML from dev #121

name: "Generate HTML"
run-name: "Generate HTML from ${{ inputs.build-ref }}"
permissions:
contents: read
# Builds, verifies, and publishes docs for ONE environment, as a run entirely independent
# of any other environment's run. Triggered (via the API, not a workflow_call) by
# docs-publish.yml, once per environment that applies to a given push (dev, prod, or both) -
# so if dev's run fails, prod's run is completely unaffected, and vice versa.
on:
workflow_dispatch:
inputs:
build-ref:
description: 'The git ref to build from'
type: string
required: true
publish-env:
description: 'Override for dev/prod. Leave blank to derive it from build-ref against vars.DOCS_PROD_BRANCH - only needs setting explicitly when DOCS_DEV_BRANCH == DOCS_PROD_BRANCH, where build-ref alone cannot tell the two builds apart.'
type: string
required: false
default: ''
jobs:
# Resolves publish-env (dev/prod) once, so neither docs-build nor publish-html
# duplicates the override-or-derive logic.
resolve-env:
name: Resolve environment
runs-on: ubuntu-latest
outputs:
publish-env: ${{ steps.resolve.outputs.publish-env }}
steps:
- name: Resolve publish-env
id: resolve
env:
PUBLISH_ENV_OVERRIDE: ${{ inputs.publish-env }}
BUILD_REF: ${{ inputs.build-ref }}
PROD_BRANCH: ${{ vars.DOCS_PROD_BRANCH }}
run: |
if [[ -n "${PUBLISH_ENV_OVERRIDE}" ]]; then
publish_env="${PUBLISH_ENV_OVERRIDE}"
elif [[ "${BUILD_REF}" == "${PROD_BRANCH}" ]]; then
publish_env="prod"
else
publish_env="dev"
fi
echo "publish-env=${publish_env}" >> $GITHUB_OUTPUT
docs-build:
name: Generate HTML
needs: resolve-env
uses: ./.github/workflows/reusable-docs-build.yml
with:
docs-dir: 'docs'
package-script: 'verify:publish'
build-ref: ${{ inputs.build-ref }}
fetch-depth: 0
publish-env: ${{ needs.resolve-env.outputs.publish-env }}
docs-verify:
name: Verify HTML
needs: docs-build
uses: ./.github/workflows/reusable-docs-verify.yml
with:
failOnWarnings: true
# Hand off to docs-publish (a separate repo) to actually publish this run's "docs"
# artifact.
publish-html:
name: Publish HTML
needs: [docs-verify, resolve-env]
runs-on: ubuntu-latest
steps:
- name: Publish to ${{ needs.resolve-env.outputs.publish-env }}
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 #v4
with:
token: ${{ secrets.DOCS_DISPATCH_TOKEN }}
repository: neo4j/docs-publish
event-type: publish-html
client-payload: |-
{
"org": "${{ github.repository_owner }}",
"repo": "${{ github.event.repository.name }}",
"run_id": "${{ github.run_id }}",
"publish_env": "${{ needs.resolve-env.outputs.publish-env }}"
}