1414 - ' mkdocs.yml'
1515 workflow_dispatch :
1616
17+ permissions :
18+ contents : write
19+
1720jobs :
1821 docs :
19- name : Build Documentation
22+ name : Build and Deploy Documentation
2023 runs-on : ubuntu-latest
2124 steps :
2225 - uses : actions/checkout@v3
26+ with :
27+ fetch-depth : 0
2328
2429 - name : Set up Python
2530 uses : actions/setup-python@v4
2631 with :
2732 python-version : " 3.10"
28- cache : ' pip'
29-
30- - name : Install dependencies
31- run : |
32- python -m pip install --upgrade pip
33- pip install mkdocs-material mkdocs-material-extensions pymdown-extensions || pip install mkdocs
34-
35- - name : Create default mkdocs config
36- run : |
37- if [ ! -f "mkdocs.yml" ]; then
38- echo "Creating default mkdocs.yml"
39- {
40- echo "site_name: Amega AI"
41- echo "theme:"
42- echo " name: material"
43- echo "nav:"
44- echo " - Home: index.md"
45- echo " - About: about.md"
46- } > mkdocs.yml
47- fi
4833
49- - name : Ensure docs structure
34+ - name : Install MkDocs and theme
5035 run : |
51- mkdir -p docs
52- if [ ! -f "docs/index.md" ]; then
53- echo "# Welcome to Amega AI" > docs/index.md
54- echo "Documentation is under construction." >> docs/index.md
55- fi
56- if [ ! -f "docs/about.md" ]; then
57- echo "# About Amega AI" > docs/about.md
58- echo "More information coming soon." >> docs/about.md
59- fi
60-
61- - name : Validate mkdocs config
62- run : |
63- if command -v mkdocs &> /dev/null; then
64- mkdocs build --strict || mkdocs build
65- else
66- echo "mkdocs not available, creating basic HTML"
67- mkdir -p site
68- cp -r docs/* site/
69- fi
70- continue-on-error : true
36+ pip install mkdocs-material==9.6.14 \
37+ mkdocs-material-extensions==1.3.1 \
38+ pymdown-extensions==10.15
7139
7240 - name : Build documentation
73- if : success() || failure()
74- run : |
75- if command -v mkdocs &> /dev/null; then
76- mkdocs build || echo "Build failed, using basic structure"
77- if [ $? -ne 0 ]; then
78- mkdir -p site
79- cp -r docs/* site/
80- fi
81- else
82- mkdir -p site
83- cp -r docs/* site/
84- fi
41+ run : mkdocs build --strict
8542
86- - name : Generate build report
87- if : always()
43+ - name : Deploy to GitHub Pages
44+ if : github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
45+ env :
46+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8847 run : |
89- echo "## Documentation Build Report" > docs-report.md
90- echo "### Status" >> docs-report.md
91- echo "- Config: $([ -f mkdocs.yml ] && echo 'FOUND' || echo 'CREATED')" >> docs-report.md
92- echo "- Build: ${{ job.steps.build.outcome || 'BASIC' }}" >> docs-report.md
93- echo "### Files" >> docs-report.md
94- echo "\`\`\`" >> docs-report.md
95- ls -R site/ >> docs-report.md
96- echo "\`\`\`" >> docs-report.md
97-
98- - name : Upload documentation
99- if : always()
100- uses : actions/upload-artifact@v4
101- with :
102- name : documentation
103- path : |
104- site/
105- docs-report.md
106- retention-days : 5
48+ git config --global user.name "github-actions[bot]"
49+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
50+ git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
51+ mkdocs gh-deploy --force
0 commit comments