Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
70 lines (66 loc) · 3.01 KB
/
Copy pathaction.yml
File metadata and controls
70 lines (66 loc) · 3.01 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
name: 'Living Documentation Generator for Markdown'
description: 'Render a technical project, a UI test catalog or a coverage matrix as a plain Markdown file, by the view its input declares, with a run report.'
inputs:
document-type:
description: 'Document to render: `technical-project`, `ui-test-catalog` or `coverage-matrix`.'
required: true
source-path:
description: 'Path to the input JSON file the document is rendered from.'
required: true
output-path:
description: 'Output directory; the document and its run report are written into it.'
required: false
default: './output/generator-markdown'
document-title:
description: 'Title of the document; optional.'
required: false
default: ''
verbose-logging:
description: 'Enable or disable verbose logging.'
required: false
default: 'false'
outputs:
output-path:
description: 'Resolved absolute output directory.'
value: ${{ steps.liv-doc-generator.outputs.output-path }}
branding:
icon: 'book-open'
color: 'green'
runs:
using: 'composite'
steps:
- name: Check Python and create the generator's venv
id: venv
shell: bash
run: |
unset PIP_TARGET PIP_PREFIX PIP_USER PIP_ROOT PIP_PYTHON PYTHONPATH
PY="$(command -v python3 || command -v python || true)"
if [ -z "$PY" ] || ! "$PY" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)'; then
echo "::error::living-doc-generator-markdown needs Python >= 3.10 on PATH. Add actions/setup-python before this step."; exit 1
fi
VENV="$RUNNER_TEMP/living-doc-generator-markdown-venv"
IDENTITY='import sys; print(sys.base_prefix, sys.version_info[:3])'
WANT="$("$PY" -c "$IDENTITY")"
HAVE=""
if [ -x "$VENV/bin/python" ]; then
HAVE="$("$VENV/bin/python" -c "$IDENTITY" 2>/dev/null || true)"
fi
if [ "$HAVE" != "$WANT" ]; then
rm -rf "$VENV"
"$PY" -m venv "$VENV" || { echo "::error::living-doc-generator-markdown: '$PY -m venv' failed; install the venv module."; exit 1; }
fi
"$VENV/bin/pip" install -r "${{ github.action_path }}/requirements.txt"
(cd "${{ github.action_path }}" && "$VENV/bin/python" -E -c 'import living_doc_utilities, generator_markdown') || {
echo "::error::living-doc-generator-markdown's requirements did not land in $VENV; check the runner's pip configuration for a 'target' or 'prefix' setting that redirects them."; exit 1; }
echo "python=$VENV/bin/python" >> "$GITHUB_OUTPUT"
- name: Run Living Documentation Generator for Markdown
id: liv-doc-generator
env:
INPUT_DOCUMENT_TYPE: ${{ inputs.document-type }}
INPUT_SOURCE_PATH: ${{ inputs.source-path }}
INPUT_OUTPUT_PATH: ${{ inputs.output-path }}
INPUT_DOCUMENT_TITLE: ${{ inputs.document-title }}
INPUT_VERBOSE_LOGGING: ${{ inputs.verbose-logging }}
run: |
"${{ steps.venv.outputs.python }}" -E "${{ github.action_path }}/main.py"
shell: bash