Skip to content

Commit c1ed9b9

Browse files
committed
Add workflow for deploying the docs
1 parent 28202a6 commit c1ed9b9

File tree

3 files changed

+126
-6
lines changed

3 files changed

+126
-6
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: "*"
8+
paths:
9+
- ".github/workflows/Documentation.yml"
10+
- "docs/**"
11+
- "src/**"
12+
- "Project.toml"
13+
pull_request:
14+
paths:
15+
- ".github/workflows/Documentation.yml"
16+
- "docs/**"
17+
- "src/**"
18+
- "Project.toml"
19+
release:
20+
21+
concurrency:
22+
# Skip intermediate builds: always.
23+
# Cancel intermediate builds: always.
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
build-docs:
29+
permissions:
30+
actions: write
31+
contents: write
32+
pull-requests: read
33+
statuses: write
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 30
36+
steps:
37+
- uses: actions/checkout@v6
38+
- uses: julia-actions/setup-julia@v2
39+
with:
40+
version: "1.12"
41+
- uses: julia-actions/cache@v2
42+
id: julia-cache
43+
- name: Instantiate docs environment
44+
shell: julia --color=yes --project=docs {0}
45+
run: |
46+
using Pkg
47+
Pkg.instantiate()
48+
- name: Build documentation
49+
run:
50+
julia --color=yes --project=docs docs/make.jl
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
- name: Save Julia depot cache on cancel or failure
54+
id: julia-cache-save
55+
if: cancelled() || failure()
56+
uses: actions/cache/save@v4
57+
with:
58+
path: |
59+
${{ steps.julia-cache.outputs.cache-paths }}
60+
key: ${{ steps.julia-cache.outputs.cache-key }}
61+
- uses: actions/upload-artifact@v5
62+
with:
63+
name: documentation-build
64+
path: docs/build
65+
retention-days: 10
66+
67+
deploy-docs:
68+
# Deploy docs only if triggers is not a PR, or a PR not from a fork.
69+
if: ${{ (github.event_name != 'pull_request') || (! github.event.pull_request.head.repo.fork) }}
70+
needs: build-docs
71+
permissions:
72+
actions: write
73+
contents: write
74+
pull-requests: read
75+
statuses: write
76+
runs-on: ubuntu-latest
77+
timeout-minutes: 30
78+
concurrency:
79+
# Have only one job pushing the docs at a time.
80+
group: docs-pushing
81+
steps:
82+
- uses: actions/checkout@v6
83+
- uses: julia-actions/setup-julia@v2
84+
with:
85+
version: "1.12"
86+
- uses: julia-actions/cache@v2
87+
id: julia-cache
88+
- uses: actions/download-artifact@v6
89+
with:
90+
name: documentation-build
91+
path: docs/build
92+
- name: Remove extra files
93+
# There may be JLD2 files generated during execution of Literate
94+
# examples, we don't need them on the website.
95+
run:
96+
rm -fv docs/build/literated/*.jld2
97+
- name: Instantiate docs environment
98+
shell: julia --color=yes {0}
99+
run: |
100+
# We only need `Documenter` for publishing the docs, let's not
101+
# reinstall the world all over again.
102+
using Pkg
103+
Pkg.add(; name="Documenter", version="1")
104+
- name: Deploy documentation
105+
run:
106+
julia --color=yes docs/deploy.jl
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
110+
- name: Save Julia depot cache on cancel or failure
111+
id: julia-cache-save
112+
if: cancelled() || failure()
113+
uses: actions/cache/save@v4
114+
with:
115+
path: |
116+
${{ steps.julia-cache.outputs.cache-paths }}
117+
key: ${{ steps.julia-cache.outputs.cache-key }}

docs/deploy.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Documenter
2+
3+
deploydocs(;
4+
repo="github.com/JuliaTesting/ParallelTestRunner.jl",
5+
devbranch="main",
6+
# Only push previews if all the relevant environment variables are non-empty. This is an
7+
# attempt to work around https://github.com/JuliaDocs/Documenter.jl/issues/2048.
8+
push_preview = all(!isempty, (get(ENV, "GITHUB_TOKEN", ""), get(ENV, "DOCUMENTER_KEY", ""))),
9+
)

docs/make.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,3 @@ makedocs(;
1717
"API Reference" => "api.md",
1818
],
1919
)
20-
21-
deploydocs(;
22-
repo="github.com/JuliaTesting/ParallelTestRunner.jl",
23-
devbranch="main",
24-
)
25-

0 commit comments

Comments
 (0)