Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing multidocs workflows in PRs #510

Merged
merged 4 commits into from
Nov 5, 2024
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
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 [email protected]
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