# Github CI with private repository in Julia

**URL:** <https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207>\
**Category:** General Usage\
**Tags:** question, pkg, github, ci, github-actions\
**Created:** [May 17, 2022, 3:53pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207 "2022-05-17T15:53:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [May 17, 2022, 3:53pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/1 "2022-05-17T15:53:20Z")

</div>

Dear Community,

I am having problems on a CI of a private repository of mine, the following error arises during the buildkpg phase of the CI:

```bash
caused by: GitError(Code:EUSER, Class:Callback, Aborting, user cancelled credential request.)

```

The reason is due to the fact that in the building phase of the environment, I do have the https link to the private package ([https://github.com/](https://github.com/)/.jl), but it seems like in the process, the CI does not recognize that it is run from my package.

How can I solve?

Thank you

The CI is the standard one:

```yaml
name: CI
on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  test:
    name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - version: '1'
            os: ubuntu-latest
            arch: x64
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: ${{ matrix.version }}
          arch: ${{ matrix.arch }}
      - uses: actions/cache@v1
        env:
          cache-name: cache-artifacts
        with:
          path: ~/.julia/artifacts
          key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
          restore-keys: |
            ${{ runner.os }}-test-${{ env.cache-name }}-
            ${{ runner.os }}-test-
            ${{ runner.os }}-
      - uses: julia-actions/julia-buildpkg@v1
      - uses: julia-actions/julia-runtest@v1
      #- uses: julia-actions/julia-processcoverage@v1
      #- uses: codecov/codecov-action@v1
      # with:
      # file: lcov.info

```

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 17, 2022, 4:34pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/2 "2022-05-17T16:34:08Z")

</div>

What code are you trying to run exactly in that “building phase of the environment”? Can you share?

---

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [May 17, 2022, 5:43pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/3 "2022-05-17T17:43:59Z")

</div>

The toml is the following:

```julia
name = ...
uuid = ...
authors = ...
version = "0.1.0"

[deps]
MYPRIVATEREPO = ...
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
...

[compat]
MathOptInterface = "1.0"
julia = "1"

```

and in the manifest, except the standard values, there is:

```julia
[[MYPRIVATEREPO]]
deps = ...
git-tree-sha1 = ...
repo-rev = "main"
repo-url = "https://github.com/<github_id>/<MYPRIVATEREPO>.jl"
uuid = ...
version = "0.1.0"

```

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 17, 2022, 7:08pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/4 "2022-05-17T19:08:47Z")

</div>

So, you have a package, say, `Foo.jl` and you also have `Foo.jl` in the `[deps]` section of the `Project.toml`? Or do you have another package that refers to your private package `Foo.jl`?

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 17, 2022, 7:14pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/5 "2022-05-17T19:14:12Z")

</div>

Generally, what you could do in situations where there is a private repository inside the `Manifest.toml` is to install it before running `buildpkg`. For example:

```julia
  - run: julia --project -e 'using Pkg; Pkg.add(; url="https://...")'
  - uses: julia-actions/julia-buildpkg@v1

```

getting access to the repository inside the GitHub Action is possible. You can use a GitHub Action like `webfactory/ssh-agent@v0.5.4` to set a `secrets.DEPLOY_KEY` from your private repository to give GitHub Actions access from one private repository to another.

EDIT: To avoid confusion. What I mean by DEPLOY\_KEY is that you add a key to the deploy keys of your private repository and put this key as a secret in the repository in which you currently have problems. Then, set that secret via `webfactory/ssh-agent` before running the `Pkg.add`.

---

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [May 17, 2022, 9:59pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/6 "2022-05-17T21:59:34Z")

</div>

I’ve tried, but I’m still having issues:

```julia
Run webfactory/ssh-agent@v0.5.4
Adding GitHub.com keys to /home/runner/.ssh/known_hosts
Starting ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-lN2HPXrnFuVC/agent.1665
SSH_AGENT_PID=1666
Adding private key(s) to agent
Identity added: (stdin) (git@github.com:davide-f/<repo>.jl.git)
Key(s) added:
4096 SHA256:yAtLh9RzQGzTIGFpDat7iegtJKxD1zBF1I+33laqnE8 git@github.com:davide-f/<repo>.jl.git (RSA)
Configuring deployment key(s)
Added deploy-key mapping: Use identity '/home/runner/.ssh/key-...' for GitHub repository davide-f/<repo>.jl
Comment for (public) key '' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.

```

The new CI.yaml is:

```yaml
name: CI
on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  test:
    name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - version: '1'
            os: ubuntu-latest
            arch: x64
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: ${{ matrix.version }}
          arch: ${{ matrix.arch }}
      - uses: webfactory/ssh-agent@v0.5.4
        with:
            ssh-private-key: ${{ secrets.SSH_SECRET }}
      - uses: actions/cache@v1
        env:
          cache-name: cache-artifacts
        with:
          path: ~/.julia/artifacts
          key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
          restore-keys: |
            ${{ runner.os }}-test-${{ env.cache-name }}-
            ${{ runner.os }}-test-
            ${{ runner.os }}-
...

```

I’ve followed the guide [ssh-agent/README.md at master · webfactory/ssh-agent · GitHub](https://github.com/webfactory/ssh-agent/blob/master/README.md#using-multiple-keys)

I put the public key into the deploy keys (named [github.com](http://github.com)) of “other” private github repo that has to be installed from another private repo

```julia
ssh-rsa <...> git@github.com:davide-f/<repo>.jl.git

```

The private key has been added into the secret named “SSH\_SECRET” of the repo2 that should install the repo1

Still, however, I have problems

Any idea?

Thank you for your help

---

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [May 17, 2022, 10:00pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/7 "2022-05-17T22:00:52Z")

</div>

Yes: I have two private repos, and I am trying from repo2 to install repo1

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 18, 2022, 4:15am UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/8 "2022-05-18T04:15:41Z")

</div>

> [@davide-f](#):
>
> Still, however, I have problems

Can you be more specific? Still access denied errors?

---

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [May 18, 2022, 7:40am UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/9 "2022-05-18T07:40:24Z")

</div>

> [@davide-f](#):
>
> `Comment for (public) key '' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`

Yes, see the message before, basically the error is the last line of the first block:

```julia
Comment for (public) key '' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.

```

It seems like the keys are not recognized somehow, though it seems to me that they should be fine.

This error suggests that the SSH is not successful and as a consequence, the error I was experiencing during the building of the environment is not solved.  
The subsequent error is as follows:

```julia
ERROR: failed to clone from https://github.com/davide-f/<repo>.jl, error: GitError(Code:ERROR, Class:Net, failed to resolve address for key-cd9edd77eda3f8efb9b9586183a4d3d26afe042eb1e7e8b23e8b41238d3ef161.github.com: Name or service not known)

```

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [May 18, 2022, 9:51am UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/10 "2022-05-18T09:51:01Z")

</div>

> [@davide-f](#):
>
> `Comment for (public) key '' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`

Ah. Now I see the error. Have you looked at [Multiple deploy keys not working · Issue #88 · webfactory/ssh-agent · GitHub](https://github.com/webfactory/ssh-agent/issues/88)? I’ve setup multiple repositories with SSH keys deploying from one to the other. Most recently a few days ago, so it should work. Double check that you set the right keys.

---

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [May 26, 2022, 4:57pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/11 "2022-05-26T16:57:21Z")

</div>

Thank you, I solved.  
In particular, I cloned the repo first and then installed it separately.  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![dmoored4](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmoored4/32/18311_2.png) [@dmoored4](https://discourse.julialang.org/u/dmoored4)\
**Post date:** [June 23, 2022, 5:34pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/12 "2022-06-23T17:34:05Z")

</div>

I’m having the same issue and I can’t figure out how to get the `webfactory ssh-agent` to work for multiple keys to different private repos. Would you mind sharing what your `CI.yml` looks like now with the fix you mentioned above?

---

<div class="post-metadata">

**Author:** ![davide-f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide-f/32/33780_2.png) [@davide-f](https://discourse.julialang.org/u/davide-f)\
**Post date:** [June 26, 2022, 1:57pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/13 "2022-06-26T13:57:39Z")

</div>

Here it is

```yaml
name: CI
on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  test:
    name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - version: '1'
            os: ubuntu-latest
            arch: x64
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: ${{ matrix.version }}
          arch: ${{ matrix.arch }}
      - uses: webfactory/ssh-agent@v0.5.4
        with:
            ssh-private-key: ${{ secrets.SSH_SECRET }}
      - name: Clone Games.jl
        run: git clone https://github.com/davide-f/{MyPrivateRepo}.jl
      - name: Install private repo
        run: julia --project -e 'using Pkg; Pkg.add(; url="{MyPrivateRepo}.jl")'
      - uses: actions/cache@v1
        env:
          cache-name: cache-artifacts
        with:
          path: ~/.julia/artifacts
          key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
          restore-keys: |
            ${{ runner.os }}-test-${{ env.cache-name }}-
            ${{ runner.os }}-test-
            ${{ runner.os }}-
      - uses: julia-actions/julia-buildpkg@v1
      - uses: julia-actions/julia-runtest@v1

```

---

<div class="post-metadata">

**Author:** ![dmoored4](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmoored4/32/18311_2.png) [@dmoored4](https://discourse.julialang.org/u/dmoored4)\
**Post date:** [June 26, 2022, 2:46pm UTC](https://discourse.julialang.org/t/github-ci-with-private-repository-in-julia/81207/14 "2022-06-26T14:46:04Z")

</div>

Thank you!
