(.editorconfig)/ci: 调整格式规则,优化ci (#450)
parent
914044130c
commit
5682fba0a2
|
@ -6,4 +6,4 @@ indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = false
|
||||||
|
|
|
@ -5,7 +5,6 @@ on:
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
paths:
|
paths:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
- '.github/workflows/preview-pr-build.yaml'
|
|
||||||
- 'package.json'
|
- 'package.json'
|
||||||
- 'packages/**'
|
- 'packages/**'
|
||||||
|
|
||||||
|
@ -13,7 +12,8 @@ jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: github.event.pull_request.draft == false
|
if: github.event.pull_request.draft == false
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
preview_url: ${{ steps.deploy.outputs.url }}
|
||||||
steps:
|
steps:
|
||||||
# 第一步:检出主仓库代码
|
# 第一步:检出主仓库代码
|
||||||
- name: 检出主仓库代码
|
- name: 检出主仓库代码
|
||||||
|
@ -58,36 +58,9 @@ jobs:
|
||||||
directory: docs/.vitepress/dist # 构建输出目录
|
directory: docs/.vitepress/dist # 构建输出目录
|
||||||
|
|
||||||
# 第八步:获取预览链接并发送到 PR
|
# 第八步:获取预览链接并发送到 PR
|
||||||
- name: 评论 PR 部署链接
|
comment_on_pr:
|
||||||
uses: actions/github-script@v6
|
needs: deploy
|
||||||
|
uses: project-trans/actions/.github/workflows/comment-pr-preview-link.yml@main
|
||||||
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
script: |
|
previewUrl: ${{ needs.deploy.outputs.preview_url }}
|
||||||
const prNumber = context.payload.pull_request.number;
|
|
||||||
const previewUrl = `${{ steps.deploy.outputs.url }}`;
|
|
||||||
const commentBody = `🚀 预览部署完成! 访问链接: ${previewUrl}`;
|
|
||||||
// 获取现有评论
|
|
||||||
const { data: comments } = await github.rest.issues.listComments({
|
|
||||||
issue_number: prNumber,
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
});
|
|
||||||
// 查找评论的关键词
|
|
||||||
const existingComment = comments.find(comment =>
|
|
||||||
comment.body.includes('🚀 预览部署完成!'));
|
|
||||||
if (existingComment) {
|
|
||||||
// 如果已经有评论,更新评论
|
|
||||||
await github.rest.issues.updateComment({
|
|
||||||
comment_id: existingComment.id,
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
body: commentBody,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// 如果没有评论,创建新的评论
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
issue_number: prNumber,
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
body: commentBody,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue