Skip to content

Commit

Permalink
Attempt deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Jan 18, 2024
1 parent 8259448 commit 0aca2b5
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Aggregate
on:
push:
branches:
- main
jobs:
aggregate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.8'
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install dependencies
run: julia --project=. -e 'using Pkg; Pkg.instantiate()'
- name: Aggregate and deploy
run: |
git config user.name github-actions
git config user.email github-actions@github.com
julia --project=. docs/make.jl deploy
54 changes: 53 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Script to build the Julia-XAI MultiDocumenter docs.
#
# julia --project docs/make.jl [--temp] [deploy]
#
# When `deploy` is passed as an argument, it goes into deployment mode
# and attempts to push the generated site to gh-pages. You can also pass
# `--temp`, in which case the source repositories are cloned into a temporary
# directory (as opposed to `docs/clones`).

import MultiDocumenter as MD

clonedir = mktempdir()
Expand Down Expand Up @@ -41,5 +50,48 @@ MD.make(
search_engine = MD.SearchConfig(
index_versions = ["stable"],
engine = MD.FlexSearch
)
),
rootpath = "/XAIDocs/",
canonical_domain = "https://julia-xai.github.io/",
sitemap = true,
)

if "deploy" in ARGS
@warn "Deploying to GitHub" ARGS
gitroot = normpath(joinpath(@__DIR__, ".."))
run(`git pull`)
outbranch = "gh-pages"
has_outbranch = true
if !success(`git checkout $outbranch`)
has_outbranch = false
if !success(`git switch --orphan $outbranch`)
@error "Cannot create new orphaned branch $outbranch."
exit(1)
end
end
for file in readdir(gitroot; join = true)
endswith(file, ".git") && continue
rm(file; force = true, recursive = true)
end
for file in readdir(outpath)
cp(joinpath(outpath, file), joinpath(gitroot, file))
end
run(`git add .`)
if success(`git commit -m 'Aggregate documentation'`)
@info "Pushing updated documentation."
if has_outbranch
run(`git push`)
else
run(`git push -u origin $outbranch`)
end
run(`git checkout main`)
else
@info "No changes to aggregated documentation."
end
else
@info "Skipping deployment, 'deploy' not passed. Generated files in docs/out." ARGS
outdir = joinpath(@__DIR__, "out")
if outdir != outpath
cp(outpath, outdir, force = true)
end
end

0 comments on commit 0aca2b5

Please sign in to comment.