Skip to content

Commit db193cd

Browse files
committed
try
1 parent ed03fc9 commit db193cd

File tree

3 files changed

+110
-86
lines changed

3 files changed

+110
-86
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Comment Preview URLs
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Generate Preview URLs"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment:
11+
name: Post Preview URLs Comment
12+
runs-on: ubuntu-latest
13+
if: >
14+
github.event.workflow_run.event == 'pull_request' &&
15+
github.event.workflow_run.conclusion == 'success'
16+
permissions:
17+
pull-requests: write
18+
19+
steps:
20+
- name: Download artifacts
21+
uses: actions/download-artifact@v4
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
run-id: ${{ github.event.workflow_run.id }}
25+
26+
- name: Read PR metadata
27+
id: pr-metadata
28+
run: |
29+
PR_NUMBER=$(find . -name "pr_number.txt" -exec cat {} \;)
30+
PR_SHA=$(find . -name "pr_sha.txt" -exec cat {} \;)
31+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
32+
echo "pr_sha=$PR_SHA" >> $GITHUB_OUTPUT
33+
34+
- name: Read preview URLs
35+
id: preview-urls
36+
run: |
37+
PREVIEW_CONTENT=$(find . -name "preview_urls.txt" -exec cat {} \;)
38+
{
39+
echo 'content<<EOF'
40+
echo "$PREVIEW_CONTENT"
41+
echo EOF
42+
} >> $GITHUB_OUTPUT
43+
44+
- name: Find existing comment
45+
uses: peter-evans/find-comment@v4
46+
id: fc
47+
with:
48+
issue-number: ${{ steps.pr-metadata.outputs.pr_number }}
49+
comment-author: 'github-actions[bot]'
50+
body-includes: '本次 PR 文档预览链接'
51+
52+
- name: Create or update comment
53+
uses: peter-evans/create-or-update-comment@v4
54+
with:
55+
comment-id: ${{ steps.fc.outputs.comment-id }}
56+
issue-number: ${{ steps.pr-metadata.outputs.pr_number }}
57+
body: ${{ steps.preview-urls.outputs.content }}
58+
edit-mode: replace
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Generate Preview URLs
2+
3+
on:
4+
pull_request:
5+
branches: ["develop"]
6+
paths:
7+
- 'docs/**.rst'
8+
- 'docs/**.md'
9+
10+
jobs:
11+
generate-urls:
12+
name: Generate Preview URLs
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- name: Checkout PR branch
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Fetch base branch
24+
run: |
25+
git fetch origin develop:develop
26+
27+
- name: Generate preview URLs
28+
id: generate
29+
run: |
30+
chmod +x ci_scripts/report_preview_url.sh
31+
./ci_scripts/report_preview_url.sh ${{ github.event.pull_request.number }} > preview_urls.txt
32+
33+
- name: Upload preview URLs as artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: preview-urls-${{ github.event.pull_request.number }}
37+
path: preview_urls.txt
38+
retention-days: 1
39+
40+
- name: Save PR metadata
41+
run: |
42+
echo "${{ github.event.pull_request.number }}" > pr_number.txt
43+
echo "${{ github.event.pull_request.head.sha }}" > pr_sha.txt
44+
45+
- name: Upload PR metadata
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: pr-metadata-${{ github.event.pull_request.number }}
49+
path: |
50+
pr_number.txt
51+
pr_sha.txt
52+
retention-days: 1

.github/workflows/preview-url-report.yml

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)