更新openclaw笔记 #358
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| name: Build Docusaurus | |
| runs-on: ubuntu-latest | |
| steps: | |
| # ===== 记录开始时间 ===== | |
| - name: Record build start time | |
| run: echo "BUILD_START_TS=$(date +%s)" >> $GITHUB_ENV | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build website | |
| env: | |
| ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} | |
| ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} | |
| ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }} | |
| run: npm run build | |
| - name: Upload Build Artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: build | |
| # ===== 提取提交信息 ===== | |
| - name: Extract commit info | |
| run: | | |
| echo "COMMIT_MSG=$(git log -1 --pretty=%B | tr -d '\n')" >> $GITHUB_ENV | |
| echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV | |
| # ===== 计算构建耗时 ===== | |
| - name: Calculate build duration | |
| run: | | |
| END_TS=$(date +%s) | |
| DURATION=$((END_TS - BUILD_START_TS)) | |
| MIN=$((DURATION / 60)) | |
| SEC=$((DURATION % 60)) | |
| echo "BUILD_DURATION=${MIN} 分 ${SEC} 秒" >> $GITHUB_ENV | |
| # ===== 成功通知 ===== | |
| - name: Send success notification | |
| if: success() | |
| env: | |
| WEBHOOK_KEY: ${{ secrets.WECHAT_WEBHOOK_KEY }} | |
| run: | | |
| TIMESTAMP=$(TZ=Asia/Shanghai date "+%Y-%m-%d %H:%M:%S") | |
| REPO="${{ github.repository }}" | |
| BRANCH="${{ github.ref_name }}" | |
| REF_TYPE="${{ github.ref_type }}" | |
| ACTOR="${{ github.actor }}" | |
| ACTION_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| PAGE_URL="https://${{ github.repository_owner }}.github.io/" | |
| COMMIT_URL="https://github.com/${REPO}/commit/${{ github.sha }}" | |
| curl -X POST -H "Content-Type: application/json" \ | |
| -d "{ | |
| \"msgtype\": \"markdown\", | |
| \"markdown\": { | |
| \"content\": \"# 🚀 Docusaurus 发布通知\\n\\n---\\n\\n📦 **仓库:** ${REPO}\\n🏷️ **引用类型:** ${REF_TYPE}\\n🌿 **名称:** ${BRANCH}\\n🔖 **Commit:** [${SHORT_SHA}](${COMMIT_URL})\\n📝 **提交信息:** ${COMMIT_MSG}\\n👤 **触发人:** ${ACTOR}\\n\\n🕒 **构建耗时:** ${BUILD_DURATION}\\n⏰ **发布时间:** ${TIMESTAMP}\\n\\n🌐 **访问地址:** [点击访问](${PAGE_URL})\\n🔎 **构建详情:** [点击查看](${ACTION_URL})\\n\\n---\\n\\n## ✅ 发布状态: <font color=\\\"info\\\">成功</font>\" | |
| } | |
| }" \ | |
| https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY} | |
| # ===== 失败通知 ===== | |
| - name: Send failure notification | |
| if: failure() | |
| env: | |
| WEBHOOK_KEY: ${{ secrets.WECHAT_WEBHOOK_KEY }} | |
| run: | | |
| TIMESTAMP=$(TZ=Asia/Shanghai date "+%Y-%m-%d %H:%M:%S") | |
| REPO="${{ github.repository }}" | |
| BRANCH="${{ github.ref_name }}" | |
| REF_TYPE="${{ github.ref_type }}" | |
| ACTOR="${{ github.actor }}" | |
| ACTION_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| COMMIT_URL="https://github.com/${REPO}/commit/${{ github.sha }}" | |
| curl -X POST -H "Content-Type: application/json" \ | |
| -d "{ | |
| \"msgtype\": \"markdown\", | |
| \"markdown\": { | |
| \"content\": \"# 🚨 Docusaurus 发布失败通知\\n\\n---\\n\\n📦 **仓库:** ${REPO}\\n🏷️ **引用类型:** ${REF_TYPE}\\n🌿 **名称:** ${BRANCH}\\n🔖 **Commit:** [${SHORT_SHA}](${COMMIT_URL})\\n📝 **提交信息:** ${COMMIT_MSG}\\n👤 **触发人:** ${ACTOR}\\n\\n🕒 **构建耗时:** ${BUILD_DURATION}\\n⏰ **发布时间:** ${TIMESTAMP}\\n\\n🔎 **构建详情:** [点击查看](${ACTION_URL})\\n\\n---\\n\\n## ❌ 发布状态: <font color=\\\"warning\\\">失败</font>\" | |
| } | |
| }" \ | |
| https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY} | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| needs: build | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |