-
-
Notifications
You must be signed in to change notification settings - Fork 431
105 lines (95 loc) · 3.52 KB
/
docs.yaml
File metadata and controls
105 lines (95 loc) · 3.52 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Docs
on:
pull_request:
push:
branches:
- main
release:
types: [published]
workflow_dispatch:
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true
jobs:
build-deploy:
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.13
- name: Install dependencies
run: uv sync
- name: Copy CHANGELOG to docs
run: |
if [ -f CHANGELOG.md ]; then
cp CHANGELOG.md docs/changelog.md
else
echo "# Changelog" > docs/changelog.md
echo "" >> docs/changelog.md
echo "Changelog will be available after the first release." >> docs/changelog.md
fi
- name: Update GitHub Action version in docs
run: python scripts/update_docs_version.py
env:
GH_TOKEN: ${{ github.token }}
- name: build site
run: zensical build --clean
# PR Preview Deploy (skip forked PRs as secrets are not available)
- name: Deploy Preview
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy site --project-name=datamodel-code-generator --branch=pr-${{ github.event.pull_request.number }}
- name: Comment Preview URL on PR
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const previewUrl = 'https://pr-${{ github.event.pull_request.number }}.datamodel-code-generator.pages.dev';
const body = `📚 **Docs Preview:** ${previewUrl}`;
// Check if comment already exists
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
});
}
# Dev Deploy (on push to main)
- name: Deploy Dev
if: github.event_name == 'push'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy site --project-name=datamodel-code-generator --branch=dev
# Production Deploy (on release only)
- name: Deploy Production
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy site --project-name=datamodel-code-generator --branch=main