-
Notifications
You must be signed in to change notification settings - Fork 151
82 lines (72 loc) · 2.76 KB
/
docs.yml
File metadata and controls
82 lines (72 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Docs
on:
pull_request:
release:
types: [published]
workflow_dispatch:
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-preview:
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: ./.github/workflows/docs-deploy.yml
with:
checkout_ref: ${{ github.event.pull_request.head.sha }}
deploy_branch: pr-${{ github.event.pull_request.number }}
secrets:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
build-pr:
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/docs-deploy.yml
with:
checkout_ref: ${{ github.event.pull_request.head.sha }}
build-production:
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/docs-deploy.yml
with:
checkout_ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.sha }}
deploy_branch: main
secrets:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
comment-preview:
runs-on: ubuntu-24.04
needs: build-preview
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
permissions:
issues: write
pull-requests: write
steps:
- name: Comment Preview URL on PR
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const previewUrl = 'https://pr-${{ github.event.pull_request.number }}.fastapi-code-generator.pages.dev';
const body = `📚 **Docs Preview:** ${previewUrl}`;
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const existingComment = comments.data.find((comment) =>
comment.body && comment.body.includes('Docs Preview:')
);
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body,
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});
}