Skip to content

Commit

Permalink
Deploy docs improvements (#29)
Browse files Browse the repository at this point in the history
* Deploy docs improvements

* Update make.jl

* Create doccleanup.yml

* Update make.jl

* Update documentation.yml
  • Loading branch information
Tortar authored Nov 20, 2024
1 parent 8ec4dc0 commit 9fe0173
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/doccleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Doc Preview Cleanup

on:
pull_request:
types: [closed]

jobs:
doc-preview-cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Delete preview and history
run: |
git config user.name "Documenter.jl"
git config user.email "[email protected]"
git rm -rf "previews/PR$PRNUM"
git commit -m "delete preview"
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
env:
PRNUM: ${{ github.event.number }}

- name: Push changes
run: |
git push --force origin gh-pages-new:gh-pages
12 changes: 8 additions & 4 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ jobs:
with:
version: '1.10'
- uses: julia-actions/cache@v1
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
- name: Install Dependencies
run: |
julia --project=./docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- name: Build and Deploy
run: julia -t 2 --project=./docs ./docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
run: julia -t 2 --project=docs/ docs/make.jl
15 changes: 12 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Literate.markdown(joinpath(indir, "scenario_analysis_via_overload.jl"), outdir;
Literate.markdown(joinpath(indir, "change_expectations.jl"), outdir; credit = false)


println("Documentation Build")

@info "Building Documentation"
makedocs(
sitename = "BeforeIT.jl",
format = Documenter.HTML(prettyurls = false),
Expand All @@ -47,4 +46,14 @@ makedocs(
],
)

deploydocs(;repo = "github.com/bancaditalia/BeforeIT.jl.git")
@info "Deploying Documentation"
CI = get(ENV, "CI", nothing) == "true" || get(ENV, "GITHUB_TOKEN", nothing) !== nothing
if CI
deploydocs(
repo = "github.com/JuliaDynamics/BeforeIT.jl.git",
target = "build",
push_preview = true,
devbranch = "main",
)
end
println("Finished building and deploying docs.")

0 comments on commit 9fe0173

Please sign in to comment.