Add public key from secret variable

This commit is contained in:
Tim Schubert 2018-09-20 16:15:12 +02:00
parent a2a7be9357
commit a04ef3f222
2 changed files with 3 additions and 3 deletions

View file

@ -4,7 +4,6 @@ variables:
REFERENCE_SOLUTION: $CI_PROJECT_NAMESPACE/solutions/solutions REFERENCE_SOLUTION: $CI_PROJECT_NAMESPACE/solutions/solutions
JPLAG_PATH: /app/jplag.jar JPLAG_PATH: /app/jplag.jar
CI_REPO_HOST: $CI_REGISTRY CI_REPO_HOST: $CI_REGISTRY
SSH_PUBLIC_KEY: deploy_key.pub
stages: stages:
- test - test
@ -15,6 +14,7 @@ stages:
before_script: before_script:
## get ssh private key from secret variable ## get ssh private key from secret variable
- echo "$SSH_PUBLIC_KEY" | tr -d '\r' > deploy_key.pub
- eval $(ssh-agent -s) - eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
@ -79,7 +79,7 @@ create_projects:
- abgabesystem - abgabesystem
script: script:
- abgabesystem projects -c $CI_PROJECT_NAMESPACE -d $SSH_PUBLIC_KEY - abgabesystem projects -c $CI_PROJECT_NAMESPACE -d deploy_key.pub
only: only:
- master - master

View file

@ -63,7 +63,7 @@ You can also [automate this](https://docs.gitlab.com/ce/ci/docker/using_docker_b
Proceed by creating an API token that has access to the group of the course. Proceed by creating an API token that has access to the group of the course.
Add this token as `PRIVATE_API_TOKEN` to the [secret variables](https://docs.gitlab.com/ce/ci/variables/) of the forked abgabesystem project. Add this token as `PRIVATE_API_TOKEN` to the [secret variables](https://docs.gitlab.com/ce/ci/variables/) of the forked abgabesystem project.
Then generate an SSH deploy key and add the private part as `SSH_PRIVATE_KEY` to the secret variables. Then generate an SSH deploy key and add the private part as `SSH_PRIVATE_KEY` and the public key as `SSH_PUBLIC_KEY` to the secret variables.
The key will be used by the CI script to fetch from the student projects. The key will be used by the CI script to fetch from the student projects.
Set up the the student projects using Set up the the student projects using