entrypoint.sh 1.03 KB
Newer Older
1
#!/bin/bash
Edmund Ochieng's avatar
Edmund Ochieng committed
2
set -e
Edmund Ochieng's avatar
Edmund Ochieng committed
3
mkdir -p ~/.gitlab-runner/certs
4
cp /scripts/config.toml ~/.gitlab-runner/
5

Edmund Ochieng's avatar
Edmund Ochieng committed
6 7 8 9 10 11
# Add custom CA certificate if available
if [[ -f /secrets/custom-ca.crt ]]
then 
  cp /secrets/hostname.crt ~/.gitlab-runner/certs/
fi

Edmund Ochieng's avatar
Edmund Ochieng committed
12 13 14 15 16
# Register the runner
if [[ -f /secrets/accesskey && -f /secrets/secretkey ]]; then
    export CACHE_S3_ACCESS_KEY=$(cat /secrets/accesskey)
    export CACHE_S3_SECRET_KEY=$(cat /secrets/secretkey)
fi
17

Edmund Ochieng's avatar
Edmund Ochieng committed
18 19 20 21 22 23 24 25 26
if [[ -f /secrets/gcs-applicaton-credentials-file ]]; then
    export GOOGLE_APPLICATION_CREDENTIALS="/secrets/gcs-applicaton-credentials-file"
else
    if [[ -f /secrets/gcs-access-id && -f /secrets/gcs-private-key ]]; then
    export CACHE_GCS_ACCESS_ID=$(cat /secrets/gcs-access-id)
    # echo -e used to make private key multiline (in google json auth key private key is oneline with \n)
    export CACHE_GCS_PRIVATE_KEY=$(echo -e $(cat /secrets/gcs-private-key))
    fi
fi
27

Edmund Ochieng's avatar
Edmund Ochieng committed
28 29 30
if ! sh /scripts/register-runner; then
    exit 1
fi
31 32

# Start the runner
33
exec /entrypoint run --user=gitlab-runner --listen-address=0.0.0.0