# Deploying docs to another repo with Github Actions

**URL:** <https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459>\
**Category:** General Usage\
**Tags:** documenter, ci, github-actions\
**Created:** [July 11, 2021, 11:55am UTC](https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459 "2021-07-11T11:55:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tisztamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tisztamo/32/16200_2.png) [@tisztamo](https://discourse.julialang.org/u/tisztamo)\
**Post date:** [July 11, 2021, 11:55am UTC](https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459/1 "2021-07-11T11:55:45Z")

</div>

Trying to move a large-ish project with externally hosted documentation from Travis to Github Actions (It worked with Travis some time ago).

```julia
deploydocs(
    repo = "github.com/Circo-dev/Circo-docs.git",
    branch = "main",
    devbranch = "main",
    push_preview = true
)

```

This first attempt deployed to the source repo instead of the external one, with the following logs (Note that the docs repo has the source repo as prefix in its name):

```julia
ENV["GITHUB_REPOSITORY"]="Circo-dev/Circo" occurs in repo="github.com/Circo-dev/Circo-docs.git"
│ - ✔ ENV["GITHUB_EVENT_NAME"]="push" is "push"
│ - ✔ ENV["GITHUB_REF"] matches devbranch="main"
│ - ✔ ENV["GITHUB_ACTOR"] exists and is non-empty
│ - ✔ ENV["GITHUB_TOKEN"] exists and is non-empty

```

Renaming the docs repo did not help, it just does not deploy then.

Is this case supported with Github Actions?

---

<div class="post-metadata">

**Author:** ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)\
**Post date:** [July 19, 2021, 4:13am UTC](https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459/2 "2021-07-19T04:13:42Z")

</div>

Hmm. As far as I can tell, it _should_ work (although clearly it didn’t).

To make the `Circo-dev/docs-Circo` repo work, you could surround `deploydocs` with the following `withenv`

```julia
withenv("GITHUB_REPOSITORY" => "Circo-dev/docs-Circo") do
    deploydocs(...)
end

```

This should bypass the check that is not allowing it to deploy right now. Perhaps this gives a more illuminating error.

> [@tisztamo](#):
>
> This first attempt deployed to the source repo instead of the external one

To avoid this happening again, I would suggest removing the Documenter deploy key from the source repository – if you’re not going to deploy docs there, Documenter should not have write access to it.

---

<div class="post-metadata">

**Author:** ![tisztamo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tisztamo/32/16200_2.png) [@tisztamo](https://discourse.julialang.org/u/tisztamo)\
**Post date:** [July 19, 2021, 8:45am UTC](https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459/3 "2021-07-19T08:45:18Z")

</div>

Thank you very much, the `withenv` hack made it magically work with the renamed repo!

I am not exactly sure of the intended behavior and the goal of the [occursin](https://github.com/JuliaDocs/Documenter.jl/blob/23c160811f80ee2dcc63dcc7414dc159344a4902/src/deployconfig.jl#L325) check (repo url equivalence ignoring the protocol?), but after a quick look it seems that `deploy_folder` returns the configured target repo correctly in every case, so the magic happened later.

> [@mortenpi](#):
>
> I would suggest removing the Documenter deploy key from the source repository

I think there was no deploy key there, maybe it authenticated with GITHUB\_TOKEN? (or I have deleted and forget it in the meantime - a real possibility 🙂 )

---

<div class="post-metadata">

**Author:** ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)\
**Post date:** [July 19, 2021, 9:23am UTC](https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459/4 "2021-07-19T09:23:38Z")

</div>

> [@tisztamo](#):
>
> I think there was no deploy key there, maybe it authenticated with GITHUB\_TOKEN?

Ah, yes, looking at the logs it looks like this was indeed the case. In this case, I would suggest [removing `GITHUB_TOKEN` from the workflow](https://github.com/Circo-dev/Circo/blob/959bcc5cc847ba5303635a8303b82200ad22e481/.github/workflows/ci.yml#L69), as deploying to a different repository requires `DOCUMENTER_KEY` anyway (as far as I know).

---

<div class="post-metadata">

**Author:** ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)\
**Post date:** [July 19, 2021, 9:25am UTC](https://discourse.julialang.org/t/deploying-docs-to-another-repo-with-github-actions/64459/5 "2021-07-19T09:25:47Z")

</div>

> [@tisztamo](#):
>
> I am not exactly sure of the intended behavior and the goal of the [occursin](https://github.com/JuliaDocs/Documenter.jl/blob/23c160811f80ee2dcc63dcc7414dc159344a4902/src/deployconfig.jl#L325) check

It’s there to make sure that the deployment occurs only if the workflow runs in the correct repository (e.g. you do not want to deploy when it runs on forks).
