Skip to content

Commit 4b655e7

Browse files
authored
Check for empty CI environment variables (#1511)
* Mention that push_review doesn't work from forks * Check for empty DOCUMENTER_KEY/GITHUB_TOKEN/GITHUB_ACTOR * Clarify that deploy token and key are not both needed
1 parent 8f8c493 commit 4b655e7

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- highlight.js has been updated to `v10.5.0`, which also brings various updates to the highlighting of Julia code. Due to the changes in highlight.js, code highlighting will not work on IE11. ([#1503][github-1503])
88

9+
## Version `v0.26.2`
10+
11+
* ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511])
12+
913
## Version `v0.26.1`
1014

1115
* ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497])
@@ -729,6 +733,7 @@
729733
[github-1493]: https://github.com/JuliaDocs/Documenter.jl/pull/1493
730734
[github-1497]: https://github.com/JuliaDocs/Documenter.jl/pull/1497
731735
[github-1503]: https://github.com/JuliaDocs/Documenter.jl/pull/1503
736+
[github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511
732737

733738
[julia-38079]: https://github.com/JuliaLang/julia/issues/38079
734739

docs/src/man/hosting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ jobs:
199199
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
200200
- name: Build and deploy
201201
env:
202-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
203-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
202+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
203+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
204204
run: julia --project=docs/ docs/make.jl
205205
```
206206

src/Documenter.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ the generated html. The following entries are valid in the `versions` vector:
405405
**`push_preview`** a boolean that specifies if preview documentation should be
406406
deployed from pull requests or not. If your published documentation is hosted
407407
at `"https://USER.github.io/PACKAGE.jl/stable`, by default the preview will be
408-
hosted at `"https://USER.github.io/PACKAGE.jl/previews/PR##"`.
408+
hosted at `"https://USER.github.io/PACKAGE.jl/previews/PR##"`. This feature
409+
works for pull requests with head branch in the same repository, i.e. not from
410+
forks.
409411
410412
**`branch_previews`** is the branch to which pull request previews are deployed.
411413
It defaults to the value of `branch`.

src/deployconfig.jl

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ post_status(; kwargs...) = post_status(auto_detect_deploy_system(); kwargs...)
103103

104104
marker(x) = x ? "" : ""
105105

106+
env_nonempty(key) = !isempty(get(ENV, key, ""))
107+
106108
#############
107109
# Travis CI #
108110
#############
@@ -227,9 +229,9 @@ function deploy_folder(cfg::Travis;
227229
subfolder = "previews/PR$(something(pr_number, 0))"
228230
end
229231
## DOCUMENTER_KEY should exist (just check here and extract the value later)
230-
key_ok = haskey(ENV, "DOCUMENTER_KEY")
232+
key_ok = env_nonempty("DOCUMENTER_KEY")
231233
all_ok &= key_ok
232-
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists")
234+
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty")
233235
## Cron jobs should not deploy
234236
type_ok = cfg.travis_event_type != "cron"
235237
all_ok &= type_ok
@@ -371,20 +373,20 @@ function deploy_folder(cfg::GitHubActions;
371373
subfolder = "previews/PR$(something(pr_number, 0))"
372374
end
373375
## GITHUB_ACTOR should exist (just check here and extract the value later)
374-
actor_ok = haskey(ENV, "GITHUB_ACTOR")
376+
actor_ok = env_nonempty("GITHUB_ACTOR")
375377
all_ok &= actor_ok
376-
println(io, "- $(marker(actor_ok)) ENV[\"GITHUB_ACTOR\"] exists")
378+
println(io, "- $(marker(actor_ok)) ENV[\"GITHUB_ACTOR\"] exists and is non-empty")
377379
## GITHUB_TOKEN or DOCUMENTER_KEY should exist (just check here and extract the value later)
378-
token_ok = haskey(ENV, "GITHUB_TOKEN")
379-
key_ok = haskey(ENV, "DOCUMENTER_KEY")
380+
token_ok = env_nonempty("GITHUB_TOKEN")
381+
key_ok = env_nonempty("DOCUMENTER_KEY")
380382
auth_ok = token_ok | key_ok
381383
all_ok &= auth_ok
382384
if key_ok
383-
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists")
385+
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty")
384386
elseif token_ok
385-
println(io, "- $(marker(token_ok)) ENV[\"GITHUB_TOKEN\"] exists")
387+
println(io, "- $(marker(token_ok)) ENV[\"GITHUB_TOKEN\"] exists and is non-empty")
386388
else
387-
println(io, "- $(marker(auth_ok)) ENV[\"DOCUMENTER_KEY\"] or ENV[\"GITHUB_TOKEN\"] exists")
389+
println(io, "- $(marker(auth_ok)) ENV[\"DOCUMENTER_KEY\"] or ENV[\"GITHUB_TOKEN\"] exists and is non-empty")
388390
end
389391
print(io, "Deploying: $(marker(all_ok))")
390392
@info String(take!(io))
@@ -413,7 +415,7 @@ function deploy_folder(cfg::GitHubActions;
413415
end
414416

415417
function authentication_method(::GitHubActions)
416-
if haskey(ENV, "DOCUMENTER_KEY")
418+
if env_nonempty("DOCUMENTER_KEY")
417419
return SSH
418420
else
419421
@warn "Currently the GitHub Pages build is not triggered when " *
@@ -639,8 +641,8 @@ function deploy_folder(
639641
deploy_repo = repo
640642
end
641643

642-
key_ok = haskey(ENV, "DOCUMENTER_KEY")
643-
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists")
644+
key_ok = env_nonempty("DOCUMENTER_KEY")
645+
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty")
644646
all_ok &= key_ok
645647

646648
print(io, "Deploying to folder $(repr(subfolder)): $(marker(all_ok))")
@@ -782,8 +784,8 @@ function deploy_folder(
782784
deploy_repo = repo
783785
end
784786

785-
key_ok = haskey(ENV, "DOCUMENTER_KEY")
786-
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists")
787+
key_ok = env_nonempty("DOCUMENTER_KEY")
788+
println(io, "- $(marker(key_ok)) ENV[\"DOCUMENTER_KEY\"] exists and is non-empty")
787789
all_ok &= key_ok
788790

789791
print(io, "Deploying to folder $(repr(subfolder)): $(marker(all_ok))")

0 commit comments

Comments
 (0)