-
Notifications
You must be signed in to change notification settings - Fork 501
Support self-hosted github installations #2755
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
base: master
Are you sure you want to change the base?
Changes from 7 commits
ef38eb7
407d4b9
de1721f
438901a
be69eef
bc84016
5fb85ef
285c286
a1fa597
c992c64
ed5eeba
77ab55a
dc9337f
0e268b4
47fecbe
24f4f9c
a12fcfc
6b0f8a7
dcef3dd
d293e82
055111e
4e0c5e6
5133dd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -297,6 +297,9 @@ end | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Implementation of `DeployConfig` for deploying from GitHub Actions. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| For self-hosted GitHub installation use `GitHubActions(host, pages_url)` constructor | ||||||||||||||||||||||||||||||||||||||||||||||
tz-lom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||
| to specify the host name and a **full path** to the GitHub pages location. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| The following environment variables influences the build | ||||||||||||||||||||||||||||||||||||||||||||||
| when using the `GitHubActions` configuration: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -311,19 +314,48 @@ when using the `GitHubActions` configuration: | |||||||||||||||||||||||||||||||||||||||||||||
| - `GITHUB_TOKEN` or `DOCUMENTER_KEY`: used for authentication with GitHub, | ||||||||||||||||||||||||||||||||||||||||||||||
| see the manual section for [GitHub Actions](@ref) for more information. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - `GITHUB_API_URL`: specifies the GitHub API URL, which generally is `https://api.github.com`, | ||||||||||||||||||||||||||||||||||||||||||||||
| but may be different for self-hosted GitHub instances. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - `GITHUB_ACTOR`: name of the person or app that initiated the workflow; this is used to construct | ||||||||||||||||||||||||||||||||||||||||||||||
| API calls. | ||||||||||||||||||||||||||||||||||||||||||||||
tz-lom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| The `GITHUB_*` variables are set automatically on GitHub Actions, see the | ||||||||||||||||||||||||||||||||||||||||||||||
| [documentation](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables). | ||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||
| struct GitHubActions <: DeployConfig | ||||||||||||||||||||||||||||||||||||||||||||||
| github_repository::String | ||||||||||||||||||||||||||||||||||||||||||||||
| github_event_name::String | ||||||||||||||||||||||||||||||||||||||||||||||
| github_ref::String | ||||||||||||||||||||||||||||||||||||||||||||||
| github_host::String | ||||||||||||||||||||||||||||||||||||||||||||||
| github_api::String | ||||||||||||||||||||||||||||||||||||||||||||||
| github_pages_url::String | ||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| function GitHubActions() | ||||||||||||||||||||||||||||||||||||||||||||||
| github_repository = get(ENV, "GITHUB_REPOSITORY", "") # "JuliaDocs/Documenter.jl" | ||||||||||||||||||||||||||||||||||||||||||||||
| github_event_name = get(ENV, "GITHUB_EVENT_NAME", "") # "push", "pull_request" or "cron" (?) | ||||||||||||||||||||||||||||||||||||||||||||||
| github_ref = get(ENV, "GITHUB_REF", "") # "refs/heads/$(branchname)" for branch, "refs/tags/$(tagname)" for tags | ||||||||||||||||||||||||||||||||||||||||||||||
| return GitHubActions(github_repository, github_event_name, github_ref) | ||||||||||||||||||||||||||||||||||||||||||||||
| github_api = get(ENV, "GITHUB_API_URL", "") # https://api.github.com | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Compute GitHub Pages URL from repository | ||||||||||||||||||||||||||||||||||||||||||||||
| parts = split(github_repository, "/") | ||||||||||||||||||||||||||||||||||||||||||||||
| github_pages_url = if length(parts) == 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| owner, repo = parts | ||||||||||||||||||||||||||||||||||||||||||||||
| "https://$(owner).github.io/$(repo)/" | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| "" | ||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return GitHubActions(github_repository, github_event_name, github_ref, "github.com", github_api, github_pages_url) | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
| github_api = get(ENV, "GITHUB_API_URL", "") # https://api.github.com | |
| # Compute GitHub Pages URL from repository | |
| parts = split(github_repository, "/") | |
| github_pages_url = if length(parts) == 2 | |
| owner, repo = parts | |
| "https://$(owner).github.io/$(repo)/" | |
| else | |
| "" | |
| end | |
| return GitHubActions(github_repository, github_event_name, github_ref, "github.com", github_api, github_pages_url) | |
| # Compute GitHub Pages URL from repository | |
| parts = split(github_repository, "/") | |
| github_pages_url = if length(parts) == 2 | |
| owner, repo = parts | |
| "https://$(owner).github.io/$(repo)/" | |
| else | |
| "" | |
| end | |
| return GitHubActions(github_repository, github_event_name, github_ref, "github.com", "https://api.github.com", github_pages_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is GITHUB_API_URL something that is configurable for a self-hosted instance, or can we assume it's api.$(host)?
There's also GITHUB_SERVER_URL, which could potentially be used for determining host automatically? Or would that not be reliable and/or two automagical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can assume anything about it, I don't know exactly if it is configurable but I would expect that it is as some orgs have strict rules about domain names
I need to check GITHUB_SERVER_URL , for some reason I haven't used that, don't know if it is because we don't have it or because I've missed it
if something like that exists I would prefer to used it indeed instead of specifying it manually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that GITHUB_API_URL is mentioned in the GitHub manual as a variable they set in GitHub Action workflows.
And in the corresponding enterprise docs at https://docs.github.com/en/enterprise-server@3.18/actions/reference/workflows-and-actions/variables the example value given is http(s)://HOSTNAME/api/v3 -- so no, we can't just assume it is api.$(host) (I assume that's the URL one gest if one enables "subdomain isolation")
tz-lom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mortenpi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,8 +102,11 @@ function repofile(remote::Remote, ref, filename, linerange = nothing) | |
| return fileurl(remote, ref, filename, isnothing(linerange) ? nothing : Int(first(linerange)):Int(last(linerange))) | ||
| end | ||
|
|
||
|
|
||
| const GITHUB_HOST = "github.com" | ||
|
|
||
| """ | ||
| GitHub(user :: AbstractString, repo :: AbstractString) | ||
| GitHub(user :: AbstractString, repo :: AbstractString, [host :: AbstractString]) | ||
| GitHub(remote :: AbstractString) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took the liberty of removing |
||
|
|
||
| Represents a remote Git repository hosted on GitHub. The repository is identified by the | ||
|
|
@@ -117,16 +120,21 @@ makedocs( | |
|
|
||
| The single-argument constructor assumes that the user and repository parts are separated by | ||
| a slash (e.g. `JuliaDocs/Documenter.jl`). | ||
|
|
||
| A `host` can be provided to point to the location of the self-hosted GitHub installation. | ||
| """ | ||
| struct GitHub <: Remote | ||
| user::String | ||
| repo::String | ||
| host::String | ||
|
|
||
| GitHub(user::AbstractString, repo::AbstractString, host::AbstractString = GITHUB_HOST) = new(user, repo, host) | ||
| end | ||
| function GitHub(remote::AbstractString) | ||
| user, repo = split(remote, '/') | ||
| return GitHub(user, repo) | ||
| return GitHub(user, repo, GITHUB_HOST) | ||
| end | ||
| repourl(remote::GitHub) = "https://github.com/$(remote.user)/$(remote.repo)" | ||
| repourl(remote::GitHub) = "https://$(remote.host)/$(remote.user)/$(remote.repo)" | ||
| function fileurl(remote::GitHub, ref::AbstractString, filename::AbstractString, linerange) | ||
| url = "$(repourl(remote))/blob/$(ref)/$(filename)" | ||
| isnothing(linerange) && return url | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now needs to be moved up (it currently is in the 1.16.0 section but that version has already been released)