Last active
February 24, 2022 10:36
-
-
Save darmawan01/b600707ba10d1c2f4267717c69904336 to your computer and use it in GitHub Desktop.
Run Our Own Gitlab Runner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# See at link below for update | |
# https://gist.github.com/darmawan01/b600707ba10d1c2f4267717c69904336 | |
if [ "$1" = "init" ]; then | |
docker run -d --name gitlab-runner \ | |
--restart always \ | |
--privileged \ | |
-v $(pwd):/etc/gitlab-runner \ | |
-v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest | |
elif [ "$1" = "create" ] && [ -n "$2" ] && [ -n "$3" ]; then | |
docker run --rm -ti -v $(pwd):/etc/gitlab-runner gitlab/gitlab-runner register \ | |
--non-interactive \ | |
--name $2 \ | |
--url https://gitlab.com/ \ | |
--registration-token "$3" \ | |
--tag-list "docker" \ | |
--run-untagged \ | |
--executor docker \ | |
--docker-image "docker:latest" \ | |
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \ | |
--docker-privileged | |
else | |
echo "Usage !" | |
echo "./runner.sh init <- Init the gitlab runner" | |
echo "./runner.sh create <runner-name> <runner-token> <- Create a runner" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding runner access the server to automation
.ssh/authorization_keys