From 6ec3d3c917d5b916a3e2eefacd42b930dca50bfc Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 5 Oct 2024 14:07:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20=E4=BC=98=E5=8C=96ci=E7=9A=84?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/preview-pr-build.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/preview-pr-build.yaml b/.github/workflows/preview-pr-build.yaml index caa66a0b82..a7df3afd3a 100644 --- a/.github/workflows/preview-pr-build.yaml +++ b/.github/workflows/preview-pr-build.yaml @@ -5,6 +5,10 @@ on: types: [opened, synchronize, reopened, ready_for_review] paths: - 'content/**' + - 'config/**' + - 'static/**' + - 'themes/**' + - 'package.json' jobs: deploy: From 5d7bd5eae8d3074e8f402410c368c00ece4f2523 Mon Sep 17 00:00:00 2001 From: Lee Date: Sun, 6 Oct 2024 12:17:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?ci:=20=E5=B0=86=E5=8F=91=E9=80=81=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E9=93=BE=E6=8E=A5=E7=8B=AC=E7=AB=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/preview-pr-build.yaml | 43 ++++++------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/.github/workflows/preview-pr-build.yaml b/.github/workflows/preview-pr-build.yaml index a7df3afd3a..0038698d31 100644 --- a/.github/workflows/preview-pr-build.yaml +++ b/.github/workflows/preview-pr-build.yaml @@ -13,6 +13,8 @@ on: jobs: deploy: runs-on: ubuntu-latest + outputs: + preview_url: ${{ steps.deploy.outputs.url }} steps: - name: 检出主仓库代码 uses: actions/checkout@v4 @@ -56,37 +58,10 @@ jobs: accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT }} projectName: mtfwiki-preview directory: public - - - name: 评论 PR 部署链接 - uses: actions/github-script@v6 - with: - script: | - 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, - }); - } + # 获取预览链接并发送到PR + comment_on_pr: + needs: deploy + uses: project-trans/actions/.github/workflows/comment-pr-preview-link.yml@main + secrets: inherit + with: + previewUrl: ${{ needs.deploy.outputs.preview_url }}