Repository navigation
88 lines (81 loc) · 3.57 KB
/
Copy pathdocs-generate-pdf.yml
File metadata and controls
88 lines (81 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: "Generate PDF"
run-name: "Generate ${{ inputs.publish-env != '' && inputs.publish-env || (github.ref_name == vars.DOCS_PROD_BRANCH && 'prod' || 'dev') }} PDF from ${{ github.ref_name }}"
permissions:
contents: read
# Mirrors docs-generate-html.yml's shape (workflow_dispatch with a publish-env input,
# resolve-env -> build -> publish) and its own reusable-workflow reference convention (a
# pinned neo4j/docs-tools/...@v2 tag, not a relative path - this repo doesn't contain
# reusable-docs-pdf-build.yml itself). Still simpler than docs-generate-html.yml in one
# way: there's no docs-verify step (no equivalent check exists yet for a PDF), and
# build/publish are two plain jobs rather than a reusable-workflow call plus a verify call.
#
# No build-ref input - see docs-generate-html.yml's own comment on why: the git ref to
# build from is always whatever ref this run was itself dispatched against.
on:
workflow_dispatch:
inputs:
publish-env:
description: "The environment to publish to. Provide a value when the same branch publishes to both 'dev' and 'prod' environments. Otherwise, leave blank."
type: choice
required: false
default: ''
options:
- ''
- 'dev'
- 'prod'
jobs:
# Resolves publish-env (dev/prod) once, so publish-pdf doesn't duplicate the
# override-or-derive logic - same job as docs-generate-html.yml's own resolve-env.
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 }}
PROD_BRANCH: ${{ vars.DOCS_PROD_BRANCH }}
run: |
if [[ -n "${PUBLISH_ENV_OVERRIDE}" ]]; then
publish_env="${PUBLISH_ENV_OVERRIDE}"
elif [[ "${GITHUB_REF_NAME}" == "${PROD_BRANCH}" ]]; then
publish_env="prod"
else
publish_env="dev"
fi
echo "publish-env=${publish_env}" >> $GITHUB_OUTPUT
docs-build-pdf:
name: Generate PDF
needs: resolve-env
uses: neo4j/docs-tools/.github/workflows/reusable-docs-pdf-build.yml@v2
with:
build-ref: ${{ github.ref_name }}
fetch-depth: 0
publish-env: ${{ needs.resolve-env.outputs.publish-env }}
# Hand off to docs-publish (a separate repo) to actually publish this run's "pdf"
# artifact - same mechanism docs-generate-html.yml already uses for its "docs"
# artifact. docset/version come from docs-build-pdf itself (read back out of the
# PDF's own build path - see reusable-docs-pdf-build.yml), since there's no HTML
# directory tree here for docs-publish to infer them from the way it does for HTML.
publish-pdf:
name: Publish PDF
needs: [docs-build-pdf, 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-pdf
client-payload: |-
{
"org": "${{ github.repository_owner }}",
"repo": "${{ github.event.repository.name }}",
"run_id": "${{ github.run_id }}",
"publish_env": "${{ needs.resolve-env.outputs.publish-env }}",
"docset": "${{ needs.docs-build-pdf.outputs.docset }}",
"version": "${{ needs.docs-build-pdf.outputs.version }}"
}