forked from umami-hep/umami-preprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (94 loc) · 3.11 KB
/
Copy pathdocs.yml
File metadata and controls
103 lines (94 loc) · 3.11 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
name: docs
concurrency:
group: ${{ github.workflow }}-${{ startsWith(github.ref, 'refs/tags/') && github.sha || (github.event.pull_request.number || github.ref) }}
cancel-in-progress: true
on:
pull_request:
branches:
- "*"
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v4
- name: Setup UV
uses: astral-sh/setup-uv@v5
with:
python-version: "3.11"
- name: Set docs cache key
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Cache docs environment
uses: actions/cache@v4
with:
path: ~/.cache/docs
key: zensical-${{ env.cache_id }}
restore-keys: |
zensical-
- name: Install dependencies
run: uv sync && uv pip install -r docs/requirements.txt
- name: Build Docs
run: uv run zensical build --strict
- name: Upload docs artifact
uses: actions/upload-artifact@v4
with:
name: docs-site
path: site
- name: Deploy PR docs preview
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: site
target-folder: pr-${{ github.event.pull_request.number }}
- name: Comment docs preview link
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- upp-docs-preview -->';
const previewUrl = `https://umami-hep.github.io/umami-preprocessing/pr-${context.payload.pull_request.number}/`;
const body = `${marker}\nDocs preview: ${previewUrl}`;
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find(
(comment) =>
comment.user.type === 'Bot' && comment.body.includes(marker),
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}
- name: Deploy Docs
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: site
clean-exclude: |
pr-*