Debian Codegraph @

.github/workflows/publish-docs.yaml

raw
1 name: Publish Documentation
2
3 on:
4 workflow_call:
5 inputs:
6 version:
7 description: "Version to deploy (e.g., v0.16.0). Leave empty for dev."
8 required: false
9 type: string
10 workflow_dispatch:
11 inputs:
12 version:
13 description: "Version to deploy (e.g., v0.16.0). Leave empty for dev."
14 required: false
15 type: string
16 push:
17 branches: [main]
18 paths:
19 - docs/**
20 - Makefile
21 - build/mkdocs/**
22 release:
23 types: [published]
24
25 permissions:
26 contents: read # Set default read-only permissions
27
28 jobs:
29 build:
30 name: Build & Deploy Documentation
31 runs-on: ubuntu-latest
32 permissions:
33 contents: write
34 actions: read
35 steps:
36 - name: Harden the Runner (Step Security)
37 uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
38 with:
39 egress-policy: audit
40
41 - name: Checkout Repo
42 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
43 with:
44 fetch-depth: 0
45 persist-credentials: false
46
47 - name: Configure Git Credentials
48 run: |
49 git config user.name github-actions[bot]
50 git config user.email 41898282+github-actions[bot]@users.noreply.github.com
51 git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
52 env:
53 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54
55 - name: Setup Go
56 uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
57 with:
58 cache: false
59 go-version-file: go.mod
60
61 - name: Set executable permissions for script
62 run: chmod +x ./scripts/generate-service-config-docs.sh
63
64 - name: Generate Service Config Docs
65 run: |
66 go mod download
67 go clean -cache # Clear build cache
68 ./scripts/generate-service-config-docs.sh
69
70 - name: Build WASM module
71 run: make wasm
72
73 - name: Setup Python
74 uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
75 with:
76 python-version: "3.14.7"
77 cache: "pip"
78 cache-dependency-path: |
79 build/mkdocs/docs-requirements.txt
80
81 - name: Setup Cache
82 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
83 with:
84 key: mkdocs-material-${{ hashFiles('build/mkdocs/docs-requirements.txt') }}
85 path: .cache
86 restore-keys: |
87 mkdocs-material-
88
89 - name: Install mkdocs
90 run: |
91 pip install -r build/mkdocs/docs-requirements.txt
92
93 - name: Determine Mike Version and Aliases
94 id: mike
95 env:
96 TAG_NAME: ${{ github.event.release.tag_name }}
97 INPUT_VERSION: ${{ inputs.version }}
98 run: |
99 if [[ "${{ github.event_name }}" == "release" ]]; then
100 echo "version=${TAG_NAME}" >> "$GITHUB_OUTPUT"
101 echo "aliases=latest" >> "$GITHUB_OUTPUT"
102 elif [[ -n "${INPUT_VERSION}" ]]; then
103 echo "version=${INPUT_VERSION}" >> "$GITHUB_OUTPUT"
104 echo "aliases=latest" >> "$GITHUB_OUTPUT"
105 else
106 echo "version=dev" >> "$GITHUB_OUTPUT"
107 fi
108
109 - name: Build and Deploy
110 env:
111 ALIASES: ${{ steps.mike.outputs.aliases }}
112 VERSION: ${{ steps.mike.outputs.version }}
113 run: |
114 if [ -n "${ALIASES}" ]; then
115 mike deploy \
116 --config-file build/mkdocs/mkdocs.yaml \
117 --push \
118 --update-aliases "${VERSION}" "${ALIASES}"
119 else
120 mike deploy \
121 --config-file build/mkdocs/mkdocs.yaml \
122 --push \
123 "${VERSION}"
124 fi