Add forgejo-runner

This commit is contained in:
Tobias Reisinger 2023-12-04 21:36:32 +01:00
parent c0f57922be
commit 565509a5a9
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
12 changed files with 158 additions and 52 deletions
_ansible/roles/forgejo-runner/tasks

View file

@ -0,0 +1,36 @@
---
- name: Deploy {{ svc.name }}
tags:
- git
- forgejo
- ci
- forgejo-runner
block:
- import_tasks: steps/create-service-directory.yml
- import_tasks: steps/template-docker-compose.yml
- name: Copy the config
ansible.builtin.copy:
src: config.yml
dest: "{{ (service_path, 'config.yml') | path_join }}"
mode: '0755'
- name: Check if service.env already exists
ansible.builtin.stat:
path: "{{ (service_path, 'service.env') | path_join }}"
register: svc_env_file
- import_tasks: prompt-registration-token.yml
when: not svc_env_file.stat.exists or
force_forgejo_runner_registration | default(False)
- import_tasks: steps/template-service-env.yml
- import_tasks: steps/start-service.yml
- name: Register runner
ansible.builtin.command:
cmd: docker compose run --rm -it app sh -c 'forgejo-runner register --no-interactive --token ${FORGEJO_RUNNER_REGISTRATION_TOKEN} --instance ${FORGEJO_INSTANCE_URL}'
chdir: "{{ service_path }}"
when: not svc_env_file.stat.exists or
force_forgejo_runner_registration | default(False)

View file

@ -0,0 +1,11 @@
- name: Input forgejo-runner registration token
ansible.builtin.pause:
prompt: "Enter a secret"
echo: no
register: promt_registration_token
- name: Put registration token into env vars
ansible.builtin.set_fact:
svc_env: "{{ svc_env | combine({
'FORGEJO_RUNNER_REGISTRATION_TOKEN': promt_registration_token.user_input
}, recursive=True) }}"