1+ # .github/workflows/deploy-docs-tags.yml
2+
3+ name : Deploy Documentation - Tag Versions
4+
5+ on :
6+ push :
7+ tags :
8+ - ' v*.*.*'
9+
10+ jobs :
11+ build-and-deploy :
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 0
19+
20+ - name : Extract version from tag
21+ id : version
22+ run : |
23+ VERSION=${GITHUB_REF#refs/tags/v}
24+ echo "docs-version=$VERSION" >> $GITHUB_OUTPUT
25+ echo "Detected version: $VERSION"
26+
27+ - name : Install dependencies
28+ run : |
29+ sudo apt-get update
30+ sudo apt-get install -y doxygen graphviz plantuml
31+
32+ - name : Build documentation
33+ run : |
34+ # Create the necessary directory structure
35+ mkdir -p ../original_docs
36+
37+ # Run doxygen
38+ doxygen Doxyfile
39+
40+ # Check whether the document was generated successfully
41+ if [ ! -d "../original_docs/docs/html" ]; then
42+ echo "Error: Documentation was not generated in expected location"
43+ ls -la ../original_docs/docs/ || echo "Docs directory not found"
44+ exit 1
45+ fi
46+
47+ # Create version information file
48+ echo '<!DOCTYPE html>' > ../original_docs/docs/html/version.html
49+ echo '<html>' >> ../original_docs/docs/html/version.html
50+ echo '<head>' >> ../original_docs/docs/html/version.html
51+ echo ' <title>Version Info</title>' >> ../original_docs/docs/html/version.html
52+ echo '</head>' >> ../original_docs/docs/html/version.html
53+ echo '<body>' >> ../original_docs/docs/html/version.html
54+ echo ' <h1>Documentation Version</h1>' >> ../original_docs/docs/html/version.html
55+ echo " <p>Version: ${{ steps.version.outputs.docs-version }}</p>" >> ../original_docs/docs/html/version.html
56+ echo " <p>Tag: ${{ github.ref_name }}</p>" >> ../original_docs/docs/html/version.html
57+ echo " <p>Build Date: $(date -u)</p>" >> ../original_docs/docs/html/version.html
58+ echo " <p>Commit: ${{ github.sha }}</p>" >> ../original_docs/docs/html/version.html
59+ echo '</body>' >> ../original_docs/docs/html/version.html
60+ echo '</html>' >> ../original_docs/docs/html/version.html
61+
62+ - name : Deploy to original_docs repository
63+ env :
64+ GH_PAT : ${{ secrets.GH_PAT }}
65+ run : |
66+ # Configure git
67+ git config --global user.name "github-actions[bot]"
68+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
69+
70+ # Clone document repository
71+ git clone -b master https://${{ secrets.GH_PAT }}@github.com/FrozenLemonTee/original_docs.git deploy-repo
72+ cd deploy-repo
73+
74+ # Create versions directory if it doesn't exist
75+ mkdir -p versions
76+
77+ # Update specific version directory
78+ VERSION_DIR="versions/${{ steps.version.outputs.docs-version }}"
79+ rm -rf "$VERSION_DIR"
80+ mkdir -p "$VERSION_DIR"
81+ cp -r ../../original_docs/docs/html/* "$VERSION_DIR"/
82+
83+ # Update main index.html to include this version
84+ echo '<!DOCTYPE html>' > index.html
85+ echo '<html>' >> index.html
86+ echo '<head>' >> index.html
87+ echo ' <meta http-equiv="refresh" content="0; url=stable/index.html">' >> index.html
88+ echo '</head>' >> index.html
89+ echo '<body>' >> index.html
90+ echo ' <p>Redirecting to <a href="stable/index.html">stable documentation</a>...</p>' >> index.html
91+ echo ' <p>Available versions:</p>' >> index.html
92+ echo ' <ul>' >> index.html
93+ echo ' <li><a href="stable/index.html">Stable (master branch)</a></li>' >> index.html
94+ echo ' <li><a href="latest/index.html">Latest (test branch)</a></li>' >> index.html
95+ echo ' <li><a href="versions/">Tag versions</a></li>' >> index.html
96+ echo ' </ul>' >> index.html
97+ echo ' <p>Recent tag versions:</p>' >> index.html
98+ echo ' <ul>' >> index.html
99+
100+ # List recent tag versions (last 5)
101+ for dir in $(ls -1 versions/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r | head -5); do
102+ echo " <li><a href=\"versions/$dir/index.html\">Version $dir</a></li>" >> index.html
103+ done
104+
105+ echo ' </ul>' >> index.html
106+ echo '</body>' >> index.html
107+ echo '</html>' >> index.html
108+
109+ # Create versions/index.html to list all available versions
110+ echo '<!DOCTYPE html>' > versions/index.html
111+ echo '<html>' >> versions/index.html
112+ echo '<head>' >> versions/index.html
113+ echo ' <title>Versioned Documentation</title>' >> versions/index.html
114+ echo '</head>' >> versions/index.html
115+ echo '<body>' >> versions/index.html
116+ echo ' <h1>Versioned Documentation</h1>' >> versions/index.html
117+ echo ' <p>Select a version:</p>' >> versions/index.html
118+ echo ' <ul>' >> versions/index.html
119+
120+ # List all versions in reverse order (newest first)
121+ for dir in $(ls -1 versions/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r); do
122+ echo " <li><a href=\"$dir/index.html\">Version $dir</a></li>" >> versions/index.html
123+ done
124+
125+ echo ' </ul>' >> versions/index.html
126+ echo ' <p><a href="../stable/index.html">Stable (master branch)</a></p>' >> versions/index.html
127+ echo ' <p><a href="../latest/index.html">Latest (test branch)</a></p>' >> versions/index.html
128+ echo '</body>' >> versions/index.html
129+ echo '</html>' >> versions/index.html
130+
131+ # Submit and push
132+ git add .
133+ if git diff-index --quiet HEAD --; then
134+ echo "No changes to deploy"
135+ else
136+ git commit -m "Deploy ${{ steps.version.outputs.docs-version }} documentation from tag ${{ github.ref_name }}"
137+ git push origin master
138+ echo "✅ Tag documentation version ${{ steps.version.outputs.docs-version }} deployed successfully"
139+ fi
0 commit comments