Skip to content

Commit

Permalink
added option to set --run-untagged, --tag-list and --locked
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhiendl committed Sep 29, 2022
1 parent bf92a81 commit e48d26f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 41 deletions.
2 changes: 1 addition & 1 deletion charts/gitlab-runner-hetzner-autoscale/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: gitlab-runner-hetzner-autoscale
name: gitlab-runner-hetzner-autoscale
version: 0.0.8
version: 0.0.9
appVersion: v0.1
keywords:
- gitlab-runner
Expand Down
39 changes: 0 additions & 39 deletions charts/gitlab-runner-hetzner-autoscale/files/register.sh

This file was deleted.

51 changes: 50 additions & 1 deletion charts/gitlab-runner-hetzner-autoscale/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,56 @@ stringData:
CI_SERVER_URL: {{ .Values.runner.ciServerUrl | quote }}

register.sh: |
{{ .Files.Get "files/register.sh" | indent 4 | trim }}
#!/bin/bash
# gitlab-runner data directory
DATA_DIR="/etc/gitlab-runner"
CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml}
CONFIG_TEMPLATE_FILE=${CONFIG_TEMPLATE_FILE:-/gitlab-runner-config/config.template.toml}
# custom certificate authority path
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt}
LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt"
update_ca() {
echo "Updating CA certificates..."
cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}"
update-ca-certificates --fresh >/dev/null
}
if [ -f "${CA_CERTIFICATES_PATH}" ]; then
# update the ca if the custom ca is different than the current
cmp --silent "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca
fi
# check variables for runner registration
if [[ -z "$REGISTRATION_TOKEN" ]]; then
echo "ERROR: missing env variable: REGISTRATION_TOKEN"
exit 1
fi
if [[ -z "$CI_SERVER_URL" ]]; then
echo "ERROR: missing env variable: CI_SERVER_URL"
exit 1
fi
REGISTER_ARGS=""
{{ if .Values.runner.locked }}
REGISTER_ARGS="$REGISTER_ARGS --locked"
{{ end }}
{{ if .Values.runner.tagList }}
REGISTER_ARGS="$REGISTER_ARGS --tag-list {{ join "," .Values.runner.tagList }}
{{ end }}
# register runner
gitlab-runner register \
-n \
--template-config=$CONFIG_TEMPLATE_FILE \
--config=$CONFIG_FILE \
--executor docker+machine \
--run-untagged="{{ .Values.runner.runUntagged }}" \
--docker-image=ruby:2.5 \
$REGISTER_ARGS \
config.template.toml: |
# docker+machine based on gitlab.com shared runner config:
Expand Down
3 changes: 3 additions & 0 deletions charts/gitlab-runner-hetzner-autoscale/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ hetzner:
image: "ubuntu-22.04"

runner:
locked: true
tags: []
runUntagged: true
registrationToken: ""
ciServerUrl: "https://gitlab.com/"

Expand Down

0 comments on commit e48d26f

Please sign in to comment.