Skip to content
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

Add instructions to setup CI #56

Open
Sov-trotter opened this issue Mar 29, 2022 · 4 comments
Open

Add instructions to setup CI #56

Sov-trotter opened this issue Mar 29, 2022 · 4 comments

Comments

@Sov-trotter
Copy link

Hey All. First of all great package. This makes everything really seamless.

I am hosting a private registry on a company gitlab(selfhosted) and would like to be able to run CI/CD in private packages.

eg: I have two private packages, PkgA and PkgB, with PkgB depending on PkgA.

How can I setup all the authentication stuff(locally I have to enter the id and my pat)?
Also if someone has a sample script they can share it's be really nice.

Last I am also willing to create a PR to this package with instructions for the CI once I am able to figure it out.
Thanks!!

@GunnarFarneback
Copy link
Owner

There are lots of options for authentication. On GitLab alone there are deploy keys (public or project specific), deploy tokens (group or project), and access tokens (group or project). It really depends on what mechanisms you want to use (ssh or https URLs) and what kind of security model and credentials, in CI and on personal computers. In GitLab CI credentials are best stored as group or project CI variables and sometimes you can use standard CI variables. Some credentials can be baked into URLs and some can be managed by external helpers.

For my part I have avoided all credentials business for registered Julia packages by distributing them openly on the internal network with the help of LocalPackageServer.

@Sov-trotter
Copy link
Author

Sov-trotter commented Mar 30, 2022

Thanks.
So here's the process that I can think of for my case:

@lazzarello
Copy link

lazzarello commented Apr 24, 2023

Here's my job config to publish new versions in Gitlab CI. It uses a deploy key in the Docker executor. You'll have to adapt this to use your own security standards to get the deploy key into the container. There's a bunch of ways to do it. My biggest challenge was the value of $CI_PROJECT_URL is the HTTPS syntax and I'm using SSH, thus that weirdly composed SSH_URL variable. I couldn't find a predefined variable for the full SSH URL.

push-julia-library:
  when: manual
  stage: deploy
  before_script:
    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - chmod 400 /key
    - ssh-add /key
    - git config --global user.email "$GITLAB_USER_EMAIL"
    - git config --global user.name "$GITLAB_USER_NAME"
    - julia -e 'using Pkg; Pkg.Registry.update("the_private_one")'
    - export SSH_URL="git@${CI_SERVER_HOST}:${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git"
  script:
    - julia --project -e 'using LocalRegistry; register(ignore_reregistration=true,
      repo=ENV["SSH_URL"])'

@GunnarFarneback
Copy link
Owner

export SSH_URL="git@${CI_SERVER_HOST}:${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git"

You can make it slightly more compact with $CI_PROJECT_PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants