Skip to content

Commit

Permalink
Passing multidocs workflows in PRs (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
aurorarossi authored Nov 5, 2024
1 parent d0b43f7 commit 39d1fb2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 41 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/multidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,20 @@ jobs:
else
echo "GraphNeuralNetworks: objects.inv does not exist!" && exit 1
fi
- name: Build and deploy multidocs
- name: Config git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
julia --project=docs/ docs/make-multi.jl
- name: Build multidocs
if: github.event_name == 'pull_request'
run: |
julia --project=docs/ docs/make-multi.jl PR
- name: Build and deploy multidocs
if: github.event_name != 'pull_request'
run: |
julia --project=docs/ docs/make-multi.jl
80 changes: 41 additions & 39 deletions docs/make-multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,52 +55,54 @@ MultiDocumenter.make(
cp(joinpath(@__DIR__, "logo.svg"),
joinpath(outpath, "logo.svg"))

@warn "Deploying to GitHub as MultiDocumenter"
gitroot = normpath(joinpath(@__DIR__, ".."))
run(`git pull`)
if !("PR" in ARGS)
@warn "Deploying to GitHub as MultiDocumenter"
gitroot = normpath(joinpath(@__DIR__, ".."))
run(`git pull`)

outbranch = "dep-multidocs"
has_outbranch = true
outbranch = "dep-multidocs"
has_outbranch = true

status_output = read(`git status --porcelain docs/Project.toml`, String)
if !isempty(status_output)
@info "Restoring docs/Project.toml due to changes."
run(`git restore docs/Project.toml`)
else
@info "No changes detected in docs/Project.toml."
end
status_output = read(`git status --porcelain docs/Project.toml`, String)
if !isempty(status_output)
@info "Restoring docs/Project.toml due to changes."
run(`git restore docs/Project.toml`)
else
@info "No changes detected in docs/Project.toml."
end

if !success(`git checkout -f $outbranch`)
has_outbranch = false
if !success(`git switch --orphan $outbranch`)
@error "Cannot create new orphaned branch $outbranch."
exit(1)
if !success(`git checkout -f $outbranch`)
has_outbranch = false
if !success(`git switch --orphan $outbranch`)
@error "Cannot create new orphaned branch $outbranch."
exit(1)
end
end
end

@info "Cleaning up $gitroot."
for file in readdir(gitroot; join = true)
file == "/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs" && continue
endswith(file, ".git") && continue
rm(file; force = true, recursive = true)
end
@info "Cleaning up $gitroot."
for file in readdir(gitroot; join = true)
file == "/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs" && continue
endswith(file, ".git") && continue
rm(file; force = true, recursive = true)
end

@info "Copying aggregated documentation to $gitroot."
for file in readdir(outpath)
cp(joinpath(outpath, file), joinpath(gitroot, file))
end
@info "Copying aggregated documentation to $gitroot."
for file in readdir(outpath)
cp(joinpath(outpath, file), joinpath(gitroot, file))
end

rm("/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs"; force = true, recursive = true)
rm("/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs"; force = true, recursive = true)

run(`git add .`)
if success(`git commit -m 'Aggregate documentation'`)
@info "Pushing updated documentation."
if has_outbranch
run(`git push`)
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 master`)
else
run(`git push -u origin $outbranch`)
@info "No changes to aggregated documentation."
end
run(`git checkout master`)
else
@info "No changes to aggregated documentation."
end
end

0 comments on commit 39d1fb2

Please sign in to comment.