6.0.4 #19
Workflow file for this run
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: Build on Release | |
| permissions: | |
| contents: write | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Install sub-project dependencies | |
| working-directory: projects/switch520-auto-secret | |
| run: npm install | |
| - name: Build project | |
| working-directory: projects/switch520-auto-secret | |
| run: npm run build | |
| - name: Generate patch-notes.html from release body | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const body = context.payload.release.body || 'No release notes provided.'; | |
| fs.writeFileSync('patch-notes.html', body, 'utf8'); | |
| console.log('✅ patch-notes.html generated'); | |
| # ==================== 先上传构建产物(重要!放在 orphan 之前) ==================== | |
| - name: Upload build artifacts | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| projects/switch520-auto-secret/dist/** | |
| # ==================== 关键修正:创建独立的 orphan branch ==================== | |
| - name: Push patch-notes.html to independent patch-notes branch (orphan) | |
| run: | | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # 切换到完全独立的 orphan branch(无历史) | |
| git checkout --orphan patch-notes | |
| # 清空 index 和工作目录,只保留 patch-notes.html | |
| git rm -rf --cached . >/dev/null 2>&1 || true | |
| find . -maxdepth 1 ! -name '.git' ! -name 'patch-notes.html' -exec rm -rf {} + || true | |
| # 添加并提交 | |
| git add patch-notes.html | |
| git commit -m "chore: update patch-notes.html from release ${{ github.event.release.tag_name }}" || echo "No changes" | |
| # 强制推送(保持分支干净独立) | |
| git push origin patch-notes --force | |
| echo "✅ Successfully pushed to independent patch-notes branch" |