Repository navigation
68 lines (64 loc) · 2.56 KB
/
Copy pathdocs.yml
File metadata and controls
68 lines (64 loc) · 2.56 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
name: Documentation
on:
push:
branches:
- main
tags: '*'
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
docs:
name: Build documentation
# Documenter deploys with the DOCUMENTER_KEY deploy key
permissions:
contents: read
statuses: write # report the deployed preview on pull requests
pull-requests: write # link the preview from pull requests that change the docs
actions: write # needed for julia-actions/cache to delete old caches
env:
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JULIA_DEBUG: Documenter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
fetch-depth: 1
token: ${{ github.token }}
ssh-strict: false
- uses: julia-actions/setup-julia@latest
with:
version: 'lts'
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@latest
- run: julia --project=docs/ docs/make.jl
# Documenter only reports the preview as a commit status, which is easy to miss, so
# link it from pull requests that change the documentation. Pull requests from forks
# don't get a preview.
- name: Link the preview
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v9
with:
script: |
const {owner, repo} = context.repo;
const issue_number = context.issue.number;
const files = await github.paginate(github.rest.pulls.listFiles,
{owner, repo, pull_number: issue_number, per_page: 100});
if (!files.some(file => file.filename.startsWith('docs/'))) {
return;
}
const marker = '<!-- documentation-preview -->';
const comments = await github.paginate(github.rest.issues.listComments,
{owner, repo, issue_number, per_page: 100});
if (comments.some(comment => comment.body?.startsWith(marker))) {
return;
}
const url = `https://juliagpu.github.io/oneAPI.jl/previews/PR${issue_number}/`;
await github.rest.issues.createComment({owner, repo, issue_number,
body: `${marker}\nDocumentation preview: ${url}`});