Skip to content

Commit 39d1fb2

Browse files
authored
Passing multidocs workflows in PRs (#510)
1 parent d0b43f7 commit 39d1fb2

File tree

2 files changed

+52
-41
lines changed

2 files changed

+52
-41
lines changed

.github/workflows/multidocs.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,20 @@ jobs:
103103
else
104104
echo "GraphNeuralNetworks: objects.inv does not exist!" && exit 1
105105
fi
106-
- name: Build and deploy multidocs
106+
- name: Config git
107107
env:
108108
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
109109
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
110110
run: |
111111
git config user.name github-actions
112112
git config user.email [email protected]
113-
julia --project=docs/ docs/make-multi.jl
113+
114+
- name: Build multidocs
115+
if: github.event_name == 'pull_request'
116+
run: |
117+
julia --project=docs/ docs/make-multi.jl PR
118+
119+
- name: Build and deploy multidocs
120+
if: github.event_name != 'pull_request'
121+
run: |
122+
julia --project=docs/ docs/make-multi.jl

docs/make-multi.jl

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,52 +55,54 @@ MultiDocumenter.make(
5555
cp(joinpath(@__DIR__, "logo.svg"),
5656
joinpath(outpath, "logo.svg"))
5757

58-
@warn "Deploying to GitHub as MultiDocumenter"
59-
gitroot = normpath(joinpath(@__DIR__, ".."))
60-
run(`git pull`)
58+
if !("PR" in ARGS)
59+
@warn "Deploying to GitHub as MultiDocumenter"
60+
gitroot = normpath(joinpath(@__DIR__, ".."))
61+
run(`git pull`)
6162

62-
outbranch = "dep-multidocs"
63-
has_outbranch = true
63+
outbranch = "dep-multidocs"
64+
has_outbranch = true
6465

65-
status_output = read(`git status --porcelain docs/Project.toml`, String)
66-
if !isempty(status_output)
67-
@info "Restoring docs/Project.toml due to changes."
68-
run(`git restore docs/Project.toml`)
69-
else
70-
@info "No changes detected in docs/Project.toml."
71-
end
66+
status_output = read(`git status --porcelain docs/Project.toml`, String)
67+
if !isempty(status_output)
68+
@info "Restoring docs/Project.toml due to changes."
69+
run(`git restore docs/Project.toml`)
70+
else
71+
@info "No changes detected in docs/Project.toml."
72+
end
7273

73-
if !success(`git checkout -f $outbranch`)
74-
has_outbranch = false
75-
if !success(`git switch --orphan $outbranch`)
76-
@error "Cannot create new orphaned branch $outbranch."
77-
exit(1)
74+
if !success(`git checkout -f $outbranch`)
75+
has_outbranch = false
76+
if !success(`git switch --orphan $outbranch`)
77+
@error "Cannot create new orphaned branch $outbranch."
78+
exit(1)
79+
end
7880
end
79-
end
8081

81-
@info "Cleaning up $gitroot."
82-
for file in readdir(gitroot; join = true)
83-
file == "/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs" && continue
84-
endswith(file, ".git") && continue
85-
rm(file; force = true, recursive = true)
86-
end
82+
@info "Cleaning up $gitroot."
83+
for file in readdir(gitroot; join = true)
84+
file == "/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs" && continue
85+
endswith(file, ".git") && continue
86+
rm(file; force = true, recursive = true)
87+
end
8788

88-
@info "Copying aggregated documentation to $gitroot."
89-
for file in readdir(outpath)
90-
cp(joinpath(outpath, file), joinpath(gitroot, file))
91-
end
89+
@info "Copying aggregated documentation to $gitroot."
90+
for file in readdir(outpath)
91+
cp(joinpath(outpath, file), joinpath(gitroot, file))
92+
end
9293

93-
rm("/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs"; force = true, recursive = true)
94+
rm("/home/runner/work/GraphNeuralNetworks.jl/GraphNeuralNetworks.jl/docs"; force = true, recursive = true)
9495

95-
run(`git add .`)
96-
if success(`git commit -m 'Aggregate documentation'`)
97-
@info "Pushing updated documentation."
98-
if has_outbranch
99-
run(`git push`)
96+
run(`git add .`)
97+
if success(`git commit -m 'Aggregate documentation'`)
98+
@info "Pushing updated documentation."
99+
if has_outbranch
100+
run(`git push`)
101+
else
102+
run(`git push -u origin $outbranch`)
103+
end
104+
run(`git checkout master`)
100105
else
101-
run(`git push -u origin $outbranch`)
106+
@info "No changes to aggregated documentation."
102107
end
103-
run(`git checkout master`)
104-
else
105-
@info "No changes to aggregated documentation."
106-
end
108+
end

0 commit comments

Comments
 (0)