-
-
Notifications
You must be signed in to change notification settings - Fork 435
73 lines (65 loc) · 2.75 KB
/
docs.yaml
File metadata and controls
73 lines (65 loc) · 2.75 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
name: Docs
on:
pull_request:
release:
types: [published]
workflow_dispatch:
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true
jobs:
build-preview:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/docs-deploy.yaml
with:
checkout_ref: ${{ github.event.pull_request.head.sha }}
# Fork PRs run the docs build only. Only same-repo PRs get a deploy
# branch and Cloudflare secrets for preview deployment.
deploy_branch: ${{ github.event.pull_request.head.repo.full_name == github.repository && format('pr-{0}', github.event.pull_request.number) || '' }}
secrets:
CLOUDFLARE_API_TOKEN: ${{ github.event.pull_request.head.repo.full_name == github.repository && secrets.CLOUDFLARE_API_TOKEN || '' }}
CLOUDFLARE_ACCOUNT_ID: ${{ github.event.pull_request.head.repo.full_name == github.repository && secrets.CLOUDFLARE_ACCOUNT_ID || '' }}
build-production:
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/docs-deploy.yaml
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 }}.datamodel-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(c => c.body.includes('Docs Preview:'));
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
}