diff --git a/.github/workflows/doccleanup.yml b/.github/workflows/doccleanup.yml new file mode 100644 index 0000000..43b39af --- /dev/null +++ b/.github/workflows/doccleanup.yml @@ -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 "documenter@juliadocs.github.io" + 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 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 456bd95..acbea42 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -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 diff --git a/docs/make.jl b/docs/make.jl index 08b9e59..6b8e52d 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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), @@ -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.")