Created
September 18, 2019 04:18
-
-
Save darrensapalo/7bbf3a48136f898655efa7b548ad22f7 to your computer and use it in GitHub Desktop.
Interactive process for registering a 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
| #! usr/local/bin/fish | |
| # My preferred executor type is docker. | |
| set executorType docker | |
| # My preferred docker image is node 10.16. | |
| set dockerImage node:10.16.2-jessie | |
| # Helper utility function to confirm choices. | |
| # https://stackoverflow.com/questions/16407530/how-to-get-user-confirmation-in-fish-shell | |
| function read_confirm | |
| while true | |
| read -l -P 'Do you want to continue? [y/N] ' confirm | |
| switch $confirm | |
| case Y y | |
| return 0 | |
| case '' N n | |
| return 1 | |
| end | |
| end | |
| end | |
| # ========================= | |
| # Begin interaction | |
| # ========================= | |
| echo " " | |
| echo "Registering a Gitlab Runner." | |
| echo " " | |
| read -l -P 'For what repository is this runner for? ' repository | |
| echo "You chose: " $repository | |
| if read_confirm | |
| echo " " | |
| read -l -P 'What is the runner access token for this repository? ' access_token | |
| echo "You chose: " $access_token | |
| if read_confirm | |
| echo " " | |
| echo "Registering runner $repository..." | |
| gitlab-runner register -n --name $repository --url https://gitlab.com --registration-token $access_token --tag-list darren-mbp --executor $executorType --docker-image $dockerImage | |
| echo "Restarting gitlab runner..." | |
| gitlab-runner restart | |
| echo "Finished!" | |
| echo " " | |
| exit 0 | |
| end | |
| end | |
| echo "You cancelled the operation." | |
| echo " " | |
| exit 1 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reserved.