Skip to content

Commit

Permalink
Allow docs to deploy on schedule events on GH Actions (#1773)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianlmgoddard authored Mar 15, 2022
1 parent 36ae8ef commit b6017ac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Documenter.jl changelog

## Unreleased
* ![Enhancement][badge-enhancement] Documenter now deploys documentation from scheduled jobs (`schedule` on GitHub actions). ([#1772][github-1772], [#1773][github-1773])

## Version `v0.27.14`

Expand Down Expand Up @@ -978,6 +979,8 @@
[github-1762]: https://github.com/JuliaDocs/Documenter.jl/pull/1762
[github-1770]: https://github.com/JuliaDocs/Documenter.jl/issues/1770
[github-1771]: https://github.com/JuliaDocs/Documenter.jl/pull/1771
[github-1772]: https://github.com/JuliaDocs/Documenter.jl/issues/1772
[github-1773]: https://github.com/JuliaDocs/Documenter.jl/pull/1773

[julia-38079]: https://github.com/JuliaLang/julia/issues/38079
[julia-39841]: https://github.com/JuliaLang/julia/pull/39841
Expand Down
10 changes: 5 additions & 5 deletions src/deployconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Implementation of `DeployConfig` for deploying from GitHub Actions.
The following environment variables influences the build
when using the `GitHubActions` configuration:
- `GITHUB_EVENT_NAME`: must be set to `push` or `workflow_dispatch`.
- `GITHUB_EVENT_NAME`: must be set to `push`, `workflow_dispatch`, or `schedule`.
This avoids deployment on pull request builds.
- `GITHUB_REPOSITORY`: must match the value of the `repo` keyword to [`deploydocs`](@ref).
Expand Down Expand Up @@ -327,9 +327,9 @@ function deploy_folder(cfg::GitHubActions;
println(io, "- $(marker(repo_ok)) ENV[\"GITHUB_REPOSITORY\"]=\"$(cfg.github_repository)\" occurs in repo=\"$(repo)\"")
if build_type === :release
## Do not deploy for PRs
event_ok = cfg.github_event_name == "push" || cfg.github_event_name == "workflow_dispatch"
event_ok = in(cfg.github_event_name, ["push", "workflow_dispatch", "schedule"])
all_ok &= event_ok
println(io, "- $(marker(event_ok)) ENV[\"GITHUB_EVENT_NAME\"]=\"$(cfg.github_event_name)\" is \"push\" or \"workflow_dispatch\"")
println(io, "- $(marker(event_ok)) ENV[\"GITHUB_EVENT_NAME\"]=\"$(cfg.github_event_name)\" is \"push\", \"workflow_dispatch\" or \"schedule\"")
## If a tag exist it should be a valid VersionNumber
m = match(r"^refs\/tags\/(.*)$", cfg.github_ref)
tag_nobuild = version_tag_strip_build(m.captures[1])
Expand All @@ -343,9 +343,9 @@ function deploy_folder(cfg::GitHubActions;
subfolder = m === nothing ? nothing : tag_nobuild
elseif build_type === :devbranch
## Do not deploy for PRs
event_ok = cfg.github_event_name == "push" || cfg.github_event_name == "workflow_dispatch"
event_ok = in(cfg.github_event_name, ["push", "workflow_dispatch", "schedule"])
all_ok &= event_ok
println(io, "- $(marker(event_ok)) ENV[\"GITHUB_EVENT_NAME\"]=\"$(cfg.github_event_name)\" is \"push\" or \"workflow_dispatch\"")
println(io, "- $(marker(event_ok)) ENV[\"GITHUB_EVENT_NAME\"]=\"$(cfg.github_event_name)\" is \"push\", \"workflow_dispatch\" or \"schedule\"")
## deploydocs' devbranch should match the current branch
m = match(r"^refs\/heads\/(.*)$", cfg.github_ref)
branch_ok = m === nothing ? false : String(m.captures[1]) == devbranch
Expand Down
18 changes: 18 additions & 0 deletions test/deployconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,24 @@ end end
devbranch="master", devurl="hello-world", push_preview=false)
@test !d.all_ok
end
# Build on `schedule` jobs
withenv("GITHUB_EVENT_NAME" => "schedule",
"GITHUB_REPOSITORY" => "JuliaDocs/Documenter.jl",
"GITHUB_REF" => "refs/tags/v1.2.3",
"GITHUB_ACTOR" => "github-actions",
"GITHUB_TOKEN" => "SGVsbG8sIHdvcmxkLg==",
"DOCUMENTER_KEY" => nothing,
) do
cfg = Documenter.GitHubActions()
d = Documenter.deploy_folder(cfg; repo="github.com/JuliaDocs/Documenter.jl.git",
devbranch="master", devurl="dev", push_preview=true)
@test d.all_ok
@test d.subfolder == "v1.2.3"
@test d.repo == "github.com/JuliaDocs/Documenter.jl.git"
@test d.branch == "gh-pages"
@test Documenter.authentication_method(cfg) === Documenter.HTTPS
@test Documenter.authenticated_repo_url(cfg) === "https://github-actions:[email protected]/JuliaDocs/Documenter.jl.git"
end
end end

@testset "Buildkite CI deploy configuration" begin; with_logger(NullLogger()) do
Expand Down

0 comments on commit b6017ac

Please sign in to comment.