部署用这个 #24
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: Deploy Worker Script | |
| on: | |
| push: | |
| tags: | |
| - '*' # 当任何标签被推送时触发 | |
| jobs: | |
| deploy-worker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get tag name | |
| id: get_tag | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT | |
| echo "当前标签: $TAG_NAME" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 需要完整的Git历史来获取标签信息 | |
| - name: Check if source file exists | |
| run: | | |
| if [ ! -f "少年你相信光吗" ]; then | |
| echo "错误:在项目根目录未找到 '少年你相信光吗' 文件。" | |
| exit 1 | |
| fi | |
| echo "成功找到源文件 '少年你相信光吗'" | |
| - name: Rename file to _worker.js | |
| run: | | |
| cp "少年你相信光吗" "_worker.js" | |
| echo "成功将 '少年你相信光吗' 复制为 '_worker.js'" | |
| echo "注意:文件不会提交到仓库,仅用于 Release" | |
| - name: Create zip file | |
| run: | | |
| zip Pages.zip _worker.js | |
| echo "成功将 '_worker.js' 压缩为 'Pages.zip'" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.get_tag.outputs.tag_name }} | |
| name: Pages ${{ steps.get_tag.outputs.tag_name }} | |
| body: | | |
| ## 部署信息 | |
| - **源文件**: 少年你相信光吗 | |
| - **目标文件**: _worker.js | |
| - **压缩文件**: Pages.zip | |
| - **标签**: ${{ steps.get_tag.outputs.tag_name }} | |
| - **部署时间**: ${{ github.event.head_commit.timestamp }} | |
| ## 文件变更 | |
| 已从 `少年你相信光吗` 生成 `_worker.js` 文件,并压缩为 `Pages.zip`。 | |
| draft: false | |
| prerelease: false | |
| files: Pages.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Output summary | |
| run: | | |
| echo "## 部署完成" >> $GITHUB_STEP_SUMMARY | |
| echo "- 源文件: 少年你相信光吗" >> $GITHUB_STEP_SUMMARY | |
| echo "- 目标文件: _worker.js" >> $GITHUB_STEP_SUMMARY | |
| echo "- 压缩文件: Pages.zip" >> $GITHUB_STEP_SUMMARY | |
| echo "- 标签: ${{ steps.get_tag.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- GitHub Release 已创建" >> $GITHUB_STEP_SUMMARY |