0
0
Fork 1
Spiegel von https://github.com/A6-9V/MQL5-Google-Onedrive.git synchronisiert 2026-04-11 03:50:57 +00:00
MQL5-Google-Onedrive/scripts/setup_gitlab_runner.sh
2026-02-28 12:02:51 +00:00

44 Zeilen
1,4 KiB
Bash
Ausführbare Datei

#!/usr/bin/env bash
set -euo pipefail
log_info() { echo -e "\033[0;36m[INFO]\033[0m $1"; }
log_error() { echo -e "\033[0;31m[ERROR]\033[0m $1" >&2; }
log_success() { echo -e "\033[0;32m[SUCCESS]\033[0m $1"; }
GITLAB_URL="https://gitlab.com/"
install_runner() {
if ! command -v gitlab-runner &> /dev/null; then
log_info "Installing GitLab Runner binary..."
sudo curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"
sudo chmod +x /usr/local/bin/gitlab-runner
fi
}
register_runner() {
local token=${1:-${GITLAB_RUNNER_TOKEN:-}}
if [[ -z "$token" ]]; then
log_error "GitLab Runner token is missing."
log_error "Please provide it as an argument: ./setup_gitlab_runner.sh <token>"
log_error "Or set the GITLAB_RUNNER_TOKEN environment variable."
exit 1
fi
log_info "Registering runner with token: ${token:0:10}..."
sudo gitlab-runner register \
--non-interactive \
--url "$GITLAB_URL" \
--token "$token" \
--executor "docker" \
--docker-image "python:3.10-slim" \
--description "mql5-gitlab-runner" \
--tag-list "mql5,docker,linux" \
--run-untagged="true"
}
main() {
install_runner
register_runner "${1:-}"
log_success "Runner setup complete!"
}
main "$@"