diff --git a/.github/workflows/multidocs.yml b/.github/workflows/multidocs.yml index 3d2759538..cc8a9c059 100644 --- a/.github/workflows/multidocs.yml +++ b/.github/workflows/multidocs.yml @@ -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 \ No newline at end of file + + - 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 \ No newline at end of file diff --git a/docs/make-multi.jl b/docs/make-multi.jl index 28e8f1866..268a508d8 100644 --- a/docs/make-multi.jl +++ b/docs/make-multi.jl @@ -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 \ No newline at end of file