Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,11 @@ jobs:
using Documenter: doctest
using KomaMRI
doctest(KomaMRI)'
- if: ${{ !contains( github.event.pull_request.labels.*.name, 'documentation' ) }}
name: "Building documentation (docs/make.jl)"
- name: "Building documentation (docs/make.jl)"
run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
- if: ${{ contains( github.event.pull_request.labels.*.name, 'documentation' ) }}
name: "Building documentation (docs/make.jl) - [PR] PUSH_PREVIEW"
run: julia --project=docs docs/make.jl push_preview
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
Skip:
if: contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docs-preview-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
cleanup:
name: Cleanup documentation preview
runs-on: ubuntu-latest
concurrency:
group: docs-preview-gh-pages
cancel-in-progress: false
steps:
- uses: actions/checkout@v6
with:
Expand Down
51 changes: 50 additions & 1 deletion .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ on:

permissions:
actions: read
contents: write
issues: write
pull-requests: write

jobs:
comment:
if: github.event.workflow_run.event == 'pull_request'
name: Comment documentation preview URL
name: Deploy documentation preview
runs-on: ubuntu-latest
concurrency:
group: docs-preview-gh-pages
cancel-in-progress: false
steps:
- name: Find pull request
id: pr
Expand All @@ -38,6 +42,16 @@ jobs:
pull_number: pr.number,
});

if (data.state !== 'open') {
core.info('Pull request is not open.');
return;
}

if (data.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`) {
core.info('Pull request is not from this repository.');
return;
}

if (!data.labels.some(label => label.name === 'documentation')) {
core.info('Pull request does not have the documentation label.');
return;
Expand All @@ -63,6 +77,41 @@ jobs:

core.setOutput('number', pr.number);

- uses: actions/checkout@v6
if: steps.pr.outputs.number != ''
with:
ref: refs/pull/${{ steps.pr.outputs.number }}/merge
fetch-depth: 0

- uses: julia-actions/setup-julia@v2
if: steps.pr.outputs.number != ''
with:
version: '1'

- name: "Documentation dev environment setup"
if: steps.pr.outputs.number != ''
run: |
julia --project=docs -e '
using Pkg
Pkg.develop([
PackageSpec(path=pwd(), subdir="."),
PackageSpec(path=pwd(), subdir="KomaMRIBase"),
PackageSpec(path=pwd(), subdir="KomaMRICore"),
PackageSpec(path=pwd(), subdir="KomaMRIFiles"),
PackageSpec(path=pwd(), subdir="KomaMRIPlots")
])
Pkg.instantiate()'

- name: Build and deploy preview
if: steps.pr.outputs.number != ''
run: |
GITHUB_EVENT_NAME=pull_request \
GITHUB_REF=refs/pull/${{ steps.pr.outputs.number }}/merge \
julia --project=docs docs/make.jl push_preview
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

- name: Comment preview URL
if: steps.pr.outputs.number != ''
uses: actions/github-script@v7
Expand Down
17 changes: 10 additions & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ makedocs(;
clean=false,
)

DocumenterVitepress.deploydocs(;
repo = "github.com/JuliaHealth/KomaMRI.jl",
target = joinpath(@__DIR__, "build"),
branch = "gh-pages",
devbranch = "master",
push_preview = true,
)
deploy_preview = "push_preview" in ARGS
if get(ENV, "GITHUB_EVENT_NAME", "") == "push" || deploy_preview
DocumenterVitepress.deploydocs(;
repo = "github.com/JuliaHealth/KomaMRI.jl",
target = joinpath(@__DIR__, "build"),
branch = "gh-pages",
devbranch = "master",
push_preview = deploy_preview,
)
end
Loading