mirror of
https://github.com/one-among-us/data.git
synced 2025-02-22 14:18:44 +08:00
[F] Fix preview action?
This commit is contained in:
parent
94c8de9318
commit
e156186814
20
.github/workflows/preview.yml
vendored
20
.github/workflows/preview.yml
vendored
@ -1,11 +1,9 @@
|
||||
name: PR Preview
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
# Trigger the workflow on these PR events:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened]
|
||||
# Limit to specific branches:
|
||||
branches: [ main, develop ]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -17,7 +15,11 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout PR branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
@ -36,7 +38,7 @@ jobs:
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
command: pages deploy dist --project-name=data-preview --branch=pr-${{ github.event.pull_request.number }}
|
||||
|
||||
|
||||
- name: Pull request comment
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
@ -45,7 +47,7 @@ jobs:
|
||||
const now = new Date().toISOString().substring(0, 19).replace('T', ' ');
|
||||
const reviewBody = `🐱 感谢贡献!\n\n部署了预览,在这里哦: https://pr-${prNumber}.data-preview.pages.dev\n\n🕒 最后更新: ${now} (UTC)`;
|
||||
|
||||
// 获取现有 review
|
||||
// Look for an existing review comment containing the preview message.
|
||||
const { data: reviews } = await github.rest.pulls.listReviews({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
@ -53,7 +55,7 @@ jobs:
|
||||
});
|
||||
const existingReview = reviews.find(review => review.body.includes('部署了预览'));
|
||||
if (existingReview) {
|
||||
// 如果已经有 review,更新它
|
||||
// Update the existing review comment.
|
||||
await github.rest.pulls.updateReview({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
@ -62,7 +64,7 @@ jobs:
|
||||
body: reviewBody,
|
||||
});
|
||||
} else {
|
||||
// 如果没有 review,创建新的 review
|
||||
// Create a new review comment.
|
||||
await github.rest.pulls.createReview({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
|
Loading…
Reference in New Issue
Block a user