Skip to content

Commit ab074bb

Browse files
authored
init version (#1)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Migrated documentation to Astro with improved performance and modern build tooling * Added desktop installation button with platform-specific download options * Integrated analytics services (51LA, Baidu Analytics, Microsoft Clarity) * Added RSS feed for blog content * **Documentation** * Comprehensive product overview and feature guides * Desktop and Docker Compose installation instructions * Quick-start tutorials for projects, conversations, and proposals * Technical blog posts on integration approaches and best practices * Contributor guidelines and setup instructions * **Chores** * Automated CI/CD workflows for documentation deployment to Azure Static Web Apps * Version monitoring and release tracking system * Enhanced SEO with structured data and site metadata <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent c8f524d commit ab074bb

172 files changed

Lines changed: 25024 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Azure Static Web Apps CI/CD - Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [ opened, synchronize, reopened, closed ]
9+
branches:
10+
- main
11+
12+
jobs:
13+
build_and_deploy_job:
14+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
15+
runs-on: ubuntu-latest
16+
name: Build and Deploy Job Docs
17+
permissions:
18+
contents: read
19+
env:
20+
NODE_VERSION: "20"
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
submodules: true
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "20"
30+
cache: "npm"
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Install playwright browsers
36+
run: npx playwright install --with-deps
37+
38+
- name: Build docs
39+
run: NODE_ENV=production npm run build
40+
env:
41+
CLARITY_PROJECT_ID: ${{ secrets.CLARITY_PROJECT_ID }}
42+
43+
- name: Build And Deploy
44+
id: builddeploy
45+
uses: Azure/static-web-apps-deploy@v1
46+
with:
47+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_FLOWER_DOCS }}
48+
repo_token: ${{ secrets.GITHUB_TOKEN }}
49+
action: "upload"
50+
app_location: "dist"
51+
api_location: ""
52+
skip_app_build: true
53+
54+
close_pull_request_job:
55+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
56+
runs-on: ubuntu-latest
57+
name: Close Pull Request Job
58+
steps:
59+
- name: Close Pull Request
60+
id: closepullrequest
61+
uses: Azure/static-web-apps-deploy@v1
62+
with:
63+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_ASHY_FLOWER_DOCS }}
64+
action: "close"
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
name: Version Monitor
2+
3+
# Trigger the workflow every 30 minutes and allow manual triggering
4+
on:
5+
push:
6+
branches:
7+
- main
8+
schedule:
9+
- cron: "*/30 * * * *" # Run every 30 minutes
10+
workflow_dispatch: # Allow manual trigger from GitHub Actions UI
11+
12+
# Set permissions for creating branches, commits, and pull requests
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
monitor:
19+
name: Monitor Version Changes
20+
runs-on: ubuntu-latest
21+
outputs:
22+
update_needed: ${{ steps.monitor.outputs.update_needed }}
23+
new_version: ${{ steps.monitor.outputs.new_version }}
24+
pr_created: ${{ steps.pr.outputs.pr_created }}
25+
pr_url: ${{ steps.pr.outputs.pr_url }}
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "20"
37+
38+
- name: Display configuration
39+
run: |
40+
echo "Version Monitor Configuration"
41+
echo "=========================="
42+
echo "Source URL: ${{ vars.VERSION_SOURCE_URL || 'https://desktop.dl.hagicode.com/index.json' }}"
43+
echo "Request Timeout: 30000ms"
44+
echo "Max Retries: 3"
45+
echo "Repository: ${{ github.repository }}"
46+
47+
- name: Run version monitor
48+
id: monitor
49+
run: node scripts/version-monitor.js
50+
env:
51+
VERSION_SOURCE_URL: ${{ vars.VERSION_SOURCE_URL || 'https://desktop.dl.hagicode.com/index.json' }}
52+
REQUEST_TIMEOUT: "30000"
53+
MAX_RETRIES: "3"
54+
55+
- name: Configure Git
56+
if: steps.monitor.outputs.update_needed == 'true'
57+
run: |
58+
git config --global user.name "github-actions[bot]"
59+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
60+
61+
- name: Check existing branch
62+
id: check_branch
63+
if: steps.monitor.outputs.update_needed == 'true'
64+
run: |
65+
BRANCH_NAME="version-update-${{ steps.monitor.outputs.new_version }}"
66+
echo "Checking for existing branch: $BRANCH_NAME"
67+
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
68+
echo "branch_exists=true" >> $GITHUB_OUTPUT
69+
echo "Branch $BRANCH_NAME already exists on remote"
70+
else
71+
echo "branch_exists=false" >> $GITHUB_OUTPUT
72+
echo "Branch $BRANCH_NAME does not exist on remote"
73+
fi
74+
75+
- name: Create feature branch
76+
if: steps.monitor.outputs.update_needed == 'true' && steps.check_branch.outputs.branch_exists != 'true'
77+
run: |
78+
BRANCH_NAME="version-update-${{ steps.monitor.outputs.new_version }}"
79+
git checkout -b "$BRANCH_NAME"
80+
echo "Created branch: $BRANCH_NAME"
81+
82+
- name: Commit version changes
83+
if: steps.monitor.outputs.update_needed == 'true' && steps.check_branch.outputs.branch_exists != 'true'
84+
run: |
85+
git add public/version-index.json
86+
git commit -m "chore: update version to ${{ steps.monitor.outputs.new_version }}"
87+
88+
- name: Push branch
89+
if: steps.monitor.outputs.update_needed == 'true' && steps.check_branch.outputs.branch_exists != 'true'
90+
run: |
91+
BRANCH_NAME="version-update-${{ steps.monitor.outputs.new_version }}"
92+
git push origin "$BRANCH_NAME"
93+
94+
- name: Check existing PR
95+
id: check_pr
96+
if: steps.monitor.outputs.update_needed == 'true'
97+
env:
98+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
CURRENT_VERSION: ${{ steps.monitor.outputs.new_version }}
100+
run: |
101+
echo "Checking for existing PR for version: ${CURRENT_VERSION}"
102+
EXISTING_PR=$(gh pr list \
103+
--search "chore: update version to ${CURRENT_VERSION} in:head" \
104+
--state open \
105+
--json number,title \
106+
--jq '.[0]')
107+
108+
if [ -n "$EXISTING_PR" ]; then
109+
PR_NUMBER=$(echo "$EXISTING_PR" | jq -r '.number')
110+
PR_TITLE=$(echo "$EXISTING_PR" | jq -r '.title')
111+
echo "pr_exists=true" >> $GITHUB_OUTPUT
112+
echo "existing_pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
113+
echo "existing_pr_url=$(gh pr view $PR_NUMBER --json url -q .url)" >> $GITHUB_OUTPUT
114+
echo "Found existing PR: #$PR_NUMBER - $PR_TITLE"
115+
else
116+
echo "pr_exists=false" >> $GITHUB_OUTPUT
117+
echo "No existing PR found for version ${CURRENT_VERSION}"
118+
fi
119+
120+
- name: Close previous version PRs
121+
id: close_prs
122+
if: steps.monitor.outputs.update_needed == 'true'
123+
env:
124+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
CURRENT_VERSION: ${{ steps.monitor.outputs.new_version }}
126+
run: |
127+
echo "Closing previous version PRs (excluding current version: ${CURRENT_VERSION})..."
128+
PREVIOUS_PRS=$(gh pr list \
129+
--search "chore: update version to in:head" \
130+
--state open \
131+
--json number,title \
132+
--jq '.[] | select(.title != "chore: update version to '"${CURRENT_VERSION}"'") | .number')
133+
134+
if [ -n "$PREVIOUS_PRS" ]; then
135+
echo "$PREVIOUS_PRS" | while read -r pr_number; do
136+
echo "Closing PR #$pr_number"
137+
gh pr close "$pr_number" --comment "由于新的版本更新 PR 自动关闭"
138+
done
139+
else
140+
echo "No previous version PRs to close"
141+
fi
142+
143+
- name: Create Pull Request
144+
id: pr
145+
if: steps.monitor.outputs.update_needed == 'true' && steps.check_pr.outputs.pr_exists != 'true'
146+
env:
147+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
run: |
149+
NEW_VERSION="${{ steps.monitor.outputs.new_version }}"
150+
BRANCH_NAME="version-update-${NEW_VERSION}"
151+
PR_BODY="## Version Update
152+
153+
This PR updates the version index to reflect the new version detected from the official website.
154+
155+
- **New Version**: ${NEW_VERSION}
156+
- **Source**: ${{ vars.VERSION_SOURCE_URL || 'https://desktop.dl.hagicode.com/index.json' }}
157+
- **Checked At**: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
158+
159+
### Changes
160+
- Updated \`public/version-index.json\` with the latest version data from online API
161+
162+
### Next Steps
163+
After merging this PR, the CI/CD pipeline will automatically rebuild and deploy the documentation site with the updated version information.
164+
165+
---
166+
_This PR was automatically created by the [Version Monitor](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow._"
167+
168+
gh pr create \
169+
--title "chore: update version to ${NEW_VERSION}" \
170+
--body "$PR_BODY" \
171+
--base main \
172+
--head "$BRANCH_NAME" \
173+
--label "automation,version"
174+
175+
echo "pr_created=true" >> $GITHUB_OUTPUT
176+
echo "pr_url=$(gh pr view --json url -q .url)" >> $GITHUB_OUTPUT
177+
178+
- name: Display result
179+
if: always()
180+
run: |
181+
echo "Version Monitor Result"
182+
echo "======================"
183+
echo "Update Needed: ${{ steps.monitor.outputs.update_needed }}"
184+
echo "New Version: ${{ steps.monitor.outputs.new_version }}"
185+
echo "Branch Exists: ${{ steps.check_branch.outputs.branch_exists }}"
186+
echo "PR Exists: ${{ steps.check_pr.outputs.pr_exists }}"
187+
echo "PR Created: ${{ steps.pr.outputs.pr_created }}"
188+
if [ "${{ steps.check_pr.outputs.pr_exists }}" == "true" ]; then
189+
echo "Existing PR: #${{ steps.check_pr.outputs.existing_pr_number }}"
190+
echo "Existing PR URL: ${{ steps.check_pr.outputs.existing_pr_url }}"
191+
else
192+
echo "PR URL: ${{ steps.pr.outputs.pr_url }}"
193+
fi
194+
195+
notify-version-update:
196+
needs: monitor
197+
if: needs.monitor.outputs.pr_created == 'true'
198+
runs-on: ubuntu-latest
199+
steps:
200+
- uses: HagiCode-org/haginotifier@v1
201+
with:
202+
msg_type: 'post'
203+
title: 'Version Monitor'
204+
message: |
205+
## Version Monitor
206+
207+
**状态**: 🔄 发现新版本
208+
**新版本**: ${{ needs.monitor.outputs.new_version }}
209+
**仓库**: ${{ github.repository }}
210+
**PR 链接**: ${{ needs.monitor.outputs.pr_url }}
211+
**运行详情**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
212+
env:
213+
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
214+
215+
notify-failure:
216+
needs: monitor
217+
if: failure()
218+
runs-on: ubuntu-latest
219+
steps:
220+
- uses: HagiCode-org/haginotifier@v1
221+
with:
222+
msg_type: 'post'
223+
title: 'Version Monitor'
224+
message: |
225+
## Version Monitor
226+
227+
**状态**: ❌ 失败
228+
**仓库**: ${{ github.repository }}
229+
**触发者**: ${{ github.actor }}
230+
**运行详情**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
231+
env:
232+
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Dependencies
2+
node_modules/
3+
.pnp/
4+
.pnp.js
5+
6+
# Turbo
7+
.turbo/
8+
9+
# Testing
10+
coverage/
11+
12+
# Production
13+
build/
14+
.dist/
15+
dist/
16+
17+
# Misc
18+
.DS_Store
19+
*.pem
20+
21+
# Debug
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
# Local env files
27+
.env
28+
.env.local
29+
.env.*.local
30+
31+
# Docusaurus
32+
.docusaurus/
33+
34+
# IDE
35+
.vscode/
36+
.idea/
37+
*.swp
38+
*.swo
39+
*~
40+
41+
# OS
42+
Thumbs.db
43+
44+
.claude/skills/ui-ux-pro-max/scripts/__pycache__/
45+
.astro/
46+
tsconfig.tsbuildinfo

0 commit comments

Comments
 (0)