-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (96 loc) · 3.84 KB
/
version-docs.yml
File metadata and controls
119 lines (96 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Version Documentation
on:
release:
types: [published]
permissions:
contents: write
concurrency:
group: docs-versioning
cancel-in-progress: false
jobs:
create-version:
name: Create Documentation Version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Extract version from tag
id: version
run: |
# Extract version from tag (v0.0.3 -> 0.0.3)
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Creating documentation version: $VERSION"
- name: Check if version already exists
id: check
run: |
VERSION=${{ steps.version.outputs.version }}
if grep -q "\"${VERSION}\"" website/versions.json; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "⚠️ Version ${VERSION} already exists in versions.json"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "✅ Version ${VERSION} not found, will create"
fi
- name: Setup Node.js
if: steps.check.outputs.exists == 'false'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: website/package-lock.json
- name: Install dependencies
if: steps.check.outputs.exists == 'false'
run: |
cd website
npm ci
- name: Create documentation version
if: steps.check.outputs.exists == 'false'
run: |
VERSION=${{ steps.version.outputs.version }}
cd website
echo "Running: npm run docusaurus docs:version ${VERSION}"
npm run docusaurus docs:version ${VERSION}
echo "✅ Documentation version ${VERSION} created"
echo ""
echo "Files created/modified:"
git status --short
- name: Configure Git
if: steps.check.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit and push changes
if: steps.check.outputs.exists == 'false'
run: |
VERSION=${{ steps.version.outputs.version }}
git add website/versions.json
git add website/versioned_docs/
git add website/versioned_sidebars/
git commit -m "docs: add version ${VERSION} [skip ci]
Auto-generated documentation version from release ${GITHUB_REF}
- Added version ${VERSION} to versions.json
- Created versioned_docs/version-${VERSION}/
- Created versioned_sidebars/version-${VERSION}-sidebars.json"
git push origin HEAD:main
echo "✅ Changes pushed to main branch"
echo "📚 Documentation will be available at: https://bison.lei6393.com/docs/${VERSION}/"
- name: Summary
run: |
VERSION=${{ steps.version.outputs.version }}
EXISTS=${{ steps.check.outputs.exists }}
echo "## Documentation Versioning Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version**: ${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "**Release**: ${GITHUB_REF}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "$EXISTS" == "true" ]; then
echo "⚠️ **Status**: Version already exists, skipped" >> $GITHUB_STEP_SUMMARY
else
echo "✅ **Status**: Documentation version created successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📚 **View Documentation**: [https://bison.lei6393.com/docs/${VERSION}/](https://bison.lei6393.com/docs/${VERSION}/)" >> $GITHUB_STEP_SUMMARY
fi