Skip to content

Commit ceb2798

Browse files
feat: add script to generate offline docs
Signed-off-by: Patrick Stephens <pat@fluent.do>
1 parent 92c89ce commit ceb2798

File tree

6 files changed

+73
-6
lines changed

6 files changed

+73
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build an offline version of the documentation
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
build:
7+
name: Generate documentation and upload
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- run: scripts/generate-offline.sh
15+
shell: bash
16+
17+
- name: Debug
18+
if: always()
19+
continue-on-error: true
20+
run: ls -lR
21+
shell: bash
22+
23+
- uses: actions/upload-artifacts@v4
24+
with:
25+
name: fluentdo-agent-documentation
26+
path: *.tgz
27+
if-no-files-found: error

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
gha-creds*.json
2+
.cache
3+
site/
4+
*.tar*
5+
*.tgz

docs/security/cves.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Please reach out to us at <info@fluent.do> directly for any specific concerns or
1212

1313
## OSS Version: 4.0.3
1414

15-
- [Grype Markdown Report](agent/grype-4.0.3.md)
16-
- [Grype JSON Report](agent/grype-4.0.3.json)
17-
- [Syft JSON SBOM](agent/syft-4.0.3.json)
15+
- [Grype Markdown Report](oss/grype-4.0.3.md)
16+
- [Grype JSON Report](oss/grype-4.0.3.json)
17+
- [Syft JSON SBOM](oss/syft-4.0.3.json)
1818

1919
## OSS Version: 4.0.4
2020

21-
- [Grype Markdown Report](agent/grype-4.0.4.md)
22-
- [Grype JSON Report](agent/grype-4.0.4.json)
23-
- [Syft JSON SBOM](agent/syft-4.0.4.json)
21+
- [Grype Markdown Report](oss/grype-4.0.4.md)
22+
- [Grype JSON Report](oss/grype-4.0.4.json)
23+
- [Syft JSON SBOM](oss/syft-4.0.4.json)

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ plugins:
1212
- privacy
1313
- offline
1414
- search
15+
- social
1516
- meta
1617

1718
theme:

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ mkdocs
22
mkdocs-bootswatch
33
mkdocs-minify-plugin
44
mkdocs-material
5+
mkdocs-material[imaging]

scripts/generate-offline.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
# This does not work with a symlink to this script
5+
# SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
# See https://stackoverflow.com/a/246128/24637657
7+
SOURCE=${BASH_SOURCE[0]}
8+
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
9+
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
10+
SOURCE=$(readlink "$SOURCE")
11+
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
12+
[[ $SOURCE != /* ]] && SOURCE=$SCRIPT_DIR/$SOURCE
13+
done
14+
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
15+
REPO_ROOT=${REPO_ROOT:-$SCRIPT_DIR/..}
16+
GENERATED_DOC_DIR=${GENERATED_DOC_DIR:-$REPO_ROOT/site}
17+
OUTPUT_FILE=${OUTPUT_FILE:-$REPO_ROOT/fluentdo-agent-documentation.tgz}
18+
19+
rm -rf "$GENERATED_DOC_DIR"
20+
21+
echo "Generating documentation"
22+
${CONTAINER_RUNTIME:-docker} run --rm -t \
23+
--volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \
24+
--user "$(id -u)":"$(id -g)" \
25+
-v "${REPO_ROOT}":/docs squidfunk/mkdocs-material build
26+
27+
if [[ ! -d "$GENERATED_DOC_DIR" ]]; then
28+
echo "No documentation generated, missing 'site' directory"
29+
exit 1
30+
fi
31+
32+
echo "Creating $OUTPUT_FILE"
33+
rm -f "$OUTPUT_FILE"
34+
tar -czvf "$OUTPUT_FILE" -C "$GENERATED_DOC_DIR" .

0 commit comments

Comments
 (0)