forked from maboloshi/github-chinese
-
Notifications
You must be signed in to change notification settings - Fork 0
Ci/update #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Ci/update #2
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
16f1f61
ci: 新增依赖更新
th-dd 32ffc7a
ci: 新增构建 VSCode 插件工作流
th-dd 8de9a3e
ci: 更新 vscode 扩展构建工作流
th-dd b62932e
docs: 更新 VSCode 扩展 readme 文档
th-dd 47f2c98
ci: 修复找不到锁文件的问题
th-dd c7262ae
ci: 更新工作流名称
th-dd 8cbcba1
chore: bump version from 1.0.0 to 1.0.1
th-dd 99e12dd
ci: 新增权限字段
th-dd bbcd278
合并上游仓库提交 (#3)
th-dd 412b08c
ci: 应用 AI Agent 更改
th-dd e23ed9f
ci: 应用 AI Agent 更改
th-dd 28f9cb7
ci: 应用 AI Agent 更改
th-dd 7b16de1
ci: 应用 AI Agent 更改
th-dd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| name: Build Extension | ||
|
|
||
| on: | ||
| # 定时触发:每5天自动运行一次 | ||
| schedule: | ||
| - cron: '0 0 */5 * *' | ||
|
|
||
| # 代码推送触发:当 vscode-extension 目录有变更时自动构建 | ||
| push: | ||
| paths: | ||
| - 'vscode-extension/**' | ||
|
|
||
| # PR 触发:当 PR 涉及 vscode-extension 目录变更时构建 | ||
| pull_request: | ||
| paths: | ||
| - 'vscode-extension/**' | ||
|
|
||
| # 手动触发:允许在 Actions 页面手动点击运行 | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| expires_at: ${{ steps.calc-expiry.outputs.expires_at }} | ||
| artifact_name: ${{ steps.package.outputs.artifact_name }} | ||
| vsix_path: ${{ steps.package.outputs.vsix_path }} | ||
|
|
||
| steps: | ||
| - name: 检出代码 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: 设置 Node.js 环境 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '24' | ||
|
th-dd marked this conversation as resolved.
|
||
| cache: 'npm' | ||
| cache-dependency-path: 'vscode-extension/package-lock.json' | ||
|
|
||
| - name: 进入插件目录并安装依赖 | ||
| run: | | ||
| cd vscode-extension | ||
| npm ci | ||
|
|
||
| - name: 打包 VSIX | ||
| id: package | ||
| run: | | ||
| cd vscode-extension | ||
| # 清理旧的 VSIX 文件,避免上传历史构件 | ||
| rm -f ./*.vsix | ||
| # 使用 package.json 中的 name 和 version 生成确定性的文件名 | ||
| PKG_NAME=$(node -p "require('./package.json').name") | ||
| PKG_VERSION=$(node -p "require('./package.json').version") | ||
| VSIX_FILE="${PKG_NAME}-${PKG_VERSION}.vsix" | ||
| # 以指定的文件名打包 VSIX,避免依赖 ls 和通配符 | ||
| npx @vscode/vsce package -o "$VSIX_FILE" | ||
| echo "artifact_name=$VSIX_FILE" >> $GITHUB_OUTPUT | ||
| echo "vsix_path=vscode-extension/$VSIX_FILE" >> $GITHUB_OUTPUT | ||
|
sourcery-ai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: 计算过期时间 | ||
| id: calc-expiry | ||
| run: | | ||
| EXPIRY_DATE=$(date -u -d "+5 days" '+%Y-%m-%d %H:%M UTC') | ||
| echo "expires_at=$EXPIRY_DATE" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: 上传构件 | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: github-chinese-extension | ||
| path: ${{ steps.package.outputs.vsix_path }} | ||
| retention-days: 5 | ||
| archive: false | ||
|
sourcery-ai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: 评论 PR | ||
| if: github.event_name == 'pull_request' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const artifactName = '${{ steps.package.outputs.artifact_name }}'; | ||
| const expiresAt = '${{ steps.calc-expiry.outputs.expires_at }}'; | ||
| const runId = context.runId; | ||
| const repo = context.repo; | ||
|
|
||
| const artifactUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}/artifacts`; | ||
|
|
||
| const comment = ` | ||
| ## 📦 GitHub 中文化扩展构建完成 | ||
|
|
||
| | 项目 | 详情 | | ||
| | :--- | :--- | | ||
| | **构建状态** | ✅ 成功 | | ||
| | **产物名称** | \`${artifactName}\` | | ||
| | **预计过期时间** | **${expiresAt}** | | ||
| | **下载链接** | [点击下载构件](${artifactUrl}) | | ||
|
|
||
| > [!WARNING] | ||
| > Actions 工作流工件仅保存5天,到期将永久删除 | ||
|
|
||
| --- | ||
| **工作流运行详情**:${process.env.GITHUB_SERVER_URL}/${repo.owner}/${repo.repo}/actions/runs/${runId} | ||
| `; | ||
|
|
||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| issue_number: context.issue.number, | ||
| }); | ||
|
|
||
| const botComment = comments.find(comment => | ||
| comment.user.type === 'Bot' && | ||
| comment.body.includes('GitHub 中文化扩展构建完成') | ||
| ); | ||
|
|
||
| if (botComment) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| comment_id: botComment.id, | ||
| body: comment | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: comment | ||
| }); | ||
| } | ||
|
|
||
| - name: 生成运行摘要 | ||
| if: always() | ||
| run: | | ||
| cat >> $GITHUB_STEP_SUMMARY << 'EOF' | ||
| ## 📦 GitHub 中文化扩展构建报告 | ||
|
|
||
| | 项目 | 详情 | | ||
| | :--- | :--- | | ||
| | **构建状态** | ${{ job.status == 'success' && '✅ 成功' || '❌ 失败' }} | | ||
| | **触发方式** | ${{ github.event_name }} | | ||
| | **产物名称** | `${{ steps.package.outputs.artifact_name }}` | | ||
| | **预计过期时间** | **${{ steps.calc-expiry.outputs.expires_at }}** | | ||
| EOF | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,6 @@ Desktop.ini | |
| main(local).js | ||
| # VS Code extension package | ||
| *.vsix | ||
|
|
||
| # logs | ||
| *.log | ||
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.