Skip to content

Commit caaf2a6

Browse files
chore: created reusable-validate-deploy-docs workflow
1 parent 5843a59 commit caaf2a6

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: validate-deploy-docs
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate-docs-change:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
status: ${{ steps.validate.outputs.status }}
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.12
16+
- name: Install mkdocs and plugins
17+
run: pip install mkdocs==1.6.0 mkdocs-material==9.5.32 mkdocs-print-site-plugin==2.6.0
18+
- name: Validate docs change
19+
id: validate
20+
shell: bash
21+
run: |
22+
RED='\033[0;31m'
23+
GREEN='\033[0;32m'
24+
NC='\033[0m'
25+
if mkdocs build --strict; then
26+
echo "status=success" >> "$GITHUB_OUTPUT"
27+
echo -e "${GREEN}Docs validation success${NC}"
28+
exit 1
29+
else
30+
echo "status=failure" >> "$GITHUB_OUTPUT"
31+
echo -e "${RED}Docs validation failure${NC}"
32+
exit 1
33+
fi
34+
35+
deploy-docs:
36+
needs:
37+
- validate-docs-change
38+
runs-on: ubuntu-latest
39+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
40+
steps:
41+
- uses: actions/checkout@v4
42+
- uses: actions/setup-python@v5
43+
with:
44+
python-version: 3.12
45+
- name: Install mkdocs and plugins
46+
run: pip install mkdocs==1.6.0 mkdocs-material==9.5.32 mkdocs-print-site-plugin==2.6.0
47+
- name: Build and Deploy docs
48+
id: deploy
49+
shell: bash
50+
run: |
51+
RED='\033[0;31m'
52+
GREEN='\033[0;32m'
53+
NC='\033[0m'
54+
if [ "${{ needs.validate-docs-change.outputs.status }}" == "failure" ]; then
55+
echo -e "${RED}Docs validation failed, abort merging...${NC}"
56+
exit 1
57+
fi
58+
mkdocs gh-deploy --force
59+
echo -e "${GREEN}Deployed docs on github!${NC}"

0 commit comments

Comments
 (0)