Commit d6db937a by Archer Committed by GitHub

V4.14.9 dev (#6568)

* action

* action

* rename action

* action

* action
parent 7101ba5f
...@@ -58,15 +58,5 @@ jobs: ...@@ -58,15 +58,5 @@ jobs:
path: /tmp/fastgpt-docs-${{ steps.datetime.outputs.datetime }}.tar path: /tmp/fastgpt-docs-${{ steps.datetime.outputs.datetime }}.tar
retention-days: 1 retention-days: 1
- name: Comment build status
uses: FinleyGe/github-tools@0.0.1
if: success()
with:
token: ${{ secrets.GITHUB_TOKEN }}
tool: issue-comment
title: 'Docs Preview Build:'
body: |
Build completed. Waiting for deployment...
outputs: outputs:
datetime: ${{ steps.datetime.outputs.datetime }} datetime: ${{ steps.datetime.outputs.datetime }}
...@@ -4,6 +4,8 @@ on: ...@@ -4,6 +4,8 @@ on:
workflow_run: workflow_run:
workflows: ["Build Docs Preview (Unprivileged)"] workflows: ["Build Docs Preview (Unprivileged)"]
types: [completed] types: [completed]
branches:
- '**' # 监听所有分支
permissions: permissions:
contents: read contents: read
...@@ -11,6 +13,7 @@ permissions: ...@@ -11,6 +13,7 @@ permissions:
attestations: write attestations: write
id-token: write id-token: write
pull-requests: write pull-requests: write
issues: write # Required for issue-comment (PR comments use Issues API)
jobs: jobs:
push-and-deploy: push-and-deploy:
...@@ -23,19 +26,24 @@ jobs: ...@@ -23,19 +26,24 @@ jobs:
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
// 获取触发工作流的 PR 信息
const { data: pullRequests } = await github.rest.pulls.list({ const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
state: 'open', state: 'open',
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
}); });
if (pullRequests.length === 0) { // 查找匹配的 PR(支持 fork 仓库)
core.setFailed('No open PR found for this branch'); const pr = pullRequests.find(pr =>
pr.head.ref === context.payload.workflow_run.head_branch &&
pr.head.sha === context.payload.workflow_run.head_sha
);
if (!pr) {
core.setFailed('No open PR found for this branch and commit');
return; return;
} }
const pr = pullRequests[0];
core.setOutput('number', pr.number); core.setOutput('number', pr.number);
- name: Get workflow artifacts - name: Get workflow artifacts
...@@ -107,6 +115,7 @@ jobs: ...@@ -107,6 +115,7 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
tool: issue-comment tool: issue-comment
issue-number: ${{ steps.pr.outputs.number }}
title: 'Docs Preview:' title: 'Docs Preview:'
body: | body: |
--- ---
...@@ -120,6 +129,7 @@ jobs: ...@@ -120,6 +129,7 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
tool: issue-comment tool: issue-comment
issue-number: ${{ steps.pr.outputs.number }}
title: 'Docs Preview Deployment Failed' title: 'Docs Preview Deployment Failed'
body: | body: |
Failed to deploy docs preview. Please check workflow logs. Failed to deploy docs preview. Please check workflow logs.
...@@ -88,13 +88,3 @@ jobs: ...@@ -88,13 +88,3 @@ jobs:
name: ${{ steps.config.outputs.IMAGE_NAME }}-${{ github.sha }} name: ${{ steps.config.outputs.IMAGE_NAME }}-${{ github.sha }}
path: /tmp/${{ steps.config.outputs.IMAGE_NAME }}-${{ github.sha }}.tar path: /tmp/${{ steps.config.outputs.IMAGE_NAME }}-${{ github.sha }}.tar
retention-days: 1 retention-days: 1
- name: Comment build status
uses: FinleyGe/github-tools@0.0.1
if: success()
with:
token: ${{ secrets.GITHUB_TOKEN }}
tool: issue-comment
title: 'Preview ${{ matrix.image }} Image Built:'
body: |
Build completed. Waiting for push workflow...
...@@ -4,6 +4,8 @@ on: ...@@ -4,6 +4,8 @@ on:
workflow_run: workflow_run:
workflows: ["FastGPT Build (Unprivileged)"] workflows: ["FastGPT Build (Unprivileged)"]
types: [completed] types: [completed]
branches:
- '**' # 监听所有分支
jobs: jobs:
push-preview-images: push-preview-images:
...@@ -16,6 +18,7 @@ jobs: ...@@ -16,6 +18,7 @@ jobs:
attestations: write attestations: write
id-token: write id-token: write
pull-requests: write pull-requests: write
issues: write # Required for issue-comment (PR comments use Issues API)
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
strategy: strategy:
...@@ -29,19 +32,24 @@ jobs: ...@@ -29,19 +32,24 @@ jobs:
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
// 获取触发工作流的 PR 信息
const { data: pullRequests } = await github.rest.pulls.list({ const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
state: 'open', state: 'open',
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
}); });
if (pullRequests.length === 0) { // 查找匹配的 PR(支持 fork 仓库)
core.setFailed('No open PR found for this branch'); const pr = pullRequests.find(pr =>
pr.head.ref === context.payload.workflow_run.head_branch &&
pr.head.sha === context.payload.workflow_run.head_sha
);
if (!pr) {
core.setFailed('No open PR found for this branch and commit');
return; return;
} }
const pr = pullRequests[0];
core.setOutput('number', pr.number); core.setOutput('number', pr.number);
core.setOutput('sha', context.payload.workflow_run.head_sha); core.setOutput('sha', context.payload.workflow_run.head_sha);
...@@ -106,6 +114,7 @@ jobs: ...@@ -106,6 +114,7 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
tool: issue-comment tool: issue-comment
issue-number: ${{ steps.pr.outputs.number }}
title: 'Preview ${{ matrix.image }} Image:' title: 'Preview ${{ matrix.image }} Image:'
body: | body: |
``` ```
...@@ -118,6 +127,7 @@ jobs: ...@@ -118,6 +127,7 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
tool: issue-comment tool: issue-comment
issue-number: ${{ steps.pr.outputs.number }}
title: 'Preview ${{ matrix.image }} Image Push Failed' title: 'Preview ${{ matrix.image }} Image Push Failed'
body: | body: |
Failed to push preview image. Please check workflow logs. Failed to push preview image. Please check workflow logs.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment