fix(transform): 适配 SubStore upstream 源码结构变更 #17
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 Deno Deploy | |
| on: | |
| push: | |
| branches: | |
| - multi-tenant | |
| paths-ignore: | |
| - 'README.md' | |
| - 'LICENSE' | |
| - '.gitignore' | |
| - 'docs/**' | |
| - '*.md' | |
| schedule: | |
| # 每 3 天检查一次更新并部署 | |
| - cron: '0 0 */3 * *' | |
| workflow_dispatch: | |
| inputs: | |
| force_deploy: | |
| description: '强制部署(忽略版本检查)' | |
| required: false | |
| type: boolean | |
| default: false | |
| env: | |
| SUBSTORE_REPO: sub-store-org/Sub-Store | |
| jobs: | |
| check-updates: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| deploy_backend: ${{ steps.check.outputs.deploy_backend }} | |
| backend_version: ${{ steps.check.outputs.backend_version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Restore Last Version Cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| .last-backend-version | |
| key: version-cache-deno-${{ github.ref_name }}-${{ github.run_id }} | |
| restore-keys: | | |
| version-cache-deno-${{ github.ref_name }}- | |
| - name: Check for New Releases | |
| id: check | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| SUBSTORE_REPO: ${{ env.SUBSTORE_REPO }} | |
| FORCE_DEPLOY: ${{ github.event.inputs.force_deploy || 'false' }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| RUN_ID: ${{ github.run_id }} | |
| run: node scripts/check-updates.js | |
| deploy-backend: | |
| needs: check-updates | |
| if: contains(needs.check-updates.outputs.deploy_backend, 'ACTION_START') | |
| runs-on: ubuntu-latest | |
| name: Deploy Backend | |
| steps: | |
| - name: Validate JWT_SECRET | |
| run: | | |
| if [ -z "${{ secrets.JWT_SECRET }}" ]; then | |
| echo "::error::JWT_SECRET 未设置!" | |
| exit 1 | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Inject commit info | |
| env: | |
| COMMIT_HASH: ${{ github.sha }} | |
| COMMIT_REPO: ${{ github.repository }} | |
| run: | | |
| SHORT_SHA=$(echo "$COMMIT_HASH" | cut -c1-7) | |
| sed -i "s/'__COMMIT_HASH__'/'${SHORT_SHA}'/g" dashboard/components/Footer.jsx | |
| sed -i "s|'__COMMIT_REPO__'|'${COMMIT_REPO}'|g" dashboard/components/Footer.jsx | |
| - name: Deploy to Deno Deploy | |
| env: | |
| DENO_DEPLOY_TOKEN: ${{ secrets.DENO_DEPLOY_TOKEN }} | |
| run: | | |
| deno deploy \ | |
| --app sub-store \ | |
| --prod \ | |
| --allow-node-modules \ | |
| 2>&1 | sed -E '/https?:\/\/[^[:space:]]*\.(deno\.net|deno\.com)/d' | |
| if deno deploy env list --app sub-store 2>/dev/null | grep -q '^JWT_SECRET\b'; then | |
| echo "JWT_SECRET 已存在,更新值..." | |
| deno deploy env update-value JWT_SECRET "${{ secrets.JWT_SECRET }}" --app sub-store | |
| else | |
| echo "JWT_SECRET 不存在,正在创建..." | |
| deno deploy env add JWT_SECRET "${{ secrets.JWT_SECRET }}" --app sub-store | |
| fi | |
| update-version-cache: | |
| needs: [check-updates, deploy-backend] | |
| if: always() && needs.deploy-backend.result == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Restore Last Version Cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| .last-backend-version | |
| key: version-cache-deno-${{ github.ref_name }}-${{ github.run_id }} | |
| restore-keys: | | |
| version-cache-deno-${{ github.ref_name }}- | |
| - name: Update version files | |
| run: | | |
| echo "${{ needs.check-updates.outputs.backend_version }}" > .last-backend-version | |
| - name: Save version cache | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: | | |
| .last-backend-version | |
| key: version-cache-deno-${{ github.ref_name }}-${{ github.run_id }} | |
| summary: | |
| needs: [check-updates, deploy-backend] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy Summary | |
| run: | | |
| echo "## Deno Deploy 摘要报告" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**触发方式**: \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| 组件 | 版本 | 状态 |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|------|------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| 后端 | \`${{ needs.check-updates.outputs.backend_version }}\` | \`${{ needs.deploy-backend.result }}\` |" >> $GITHUB_STEP_SUMMARY |