Skip to content

[CI] Add Report Preview URLs Workflow #5

[CI] Add Report Preview URLs Workflow

[CI] Add Report Preview URLs Workflow #5

name: Report Preview URLs
on:
pull_request:
types: [opened, synchronize, reopened]
branches: ["develop"]
paths:
- 'docs/**.rst'
- 'docs/**.md'
jobs:
report-urls:
name: Report Preview URLs
runs-on: ubuntu-latest
if: github.repository_owner == 'PaddlePaddle'
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 0
- name: Checkout PR head branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: 'pr_head'
- name: Generate comment body
id: generate-comment
run: |
chmod +x ci_scripts/report_preview_url.sh
COMMENT_BODY=$(cd pr_head && ../ci_scripts/report_preview_url.sh ${{ github.event.pull_request.number }})
{
echo 'comment_body<<EOF'
echo "$COMMENT_BODY"
echo EOF
} >> $GITHUB_OUTPUT
- name: Find previous comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '本次 PR 文档预览链接'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.generate-comment.outputs.comment_body }}
edit-mode: replace