Skip to content

Force reinstallation when self-hosted Runner is not installed but is registered with Github Runners. #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions tasks/collect_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@

- name: "Check currently registered runners for repo {{ '(RUN ONCE)' if all_runners_in_same_repo else '' }}"
ansible.builtin.uri:
url: "{{ github_full_api_url }}"
url: "{{ github_full_api_url }}{{ '?' if '?' not in github_full_api_url else '&' }}per_page={{ github_api_runners_per_page }}"
headers:
Authorization: "token {{ access_token }}"
Accept: "application/vnd.github.v3+json"
method: GET
body_format: form-urlencoded
body:
per_page: "{{ github_api_runners_per_page }}"
status_code: 200
force_basic_auth: true
register: registered_runners
Expand Down
8 changes: 8 additions & 0 deletions tasks/install_runner_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
changed_when: false
ignore_errors: true

- name: Force reinstall if runner {{ runner_name }} in registered_runners is offline (meaning the self-hosted runner is not tied to the Github runner)
ansible.builtin.set_fact:
reinstall_runner: true
when:
- not reinstall_runner
- runner_name in (registered_runners.json.runners | map(attribute='name') | list)
- (registered_runners.json.runners | selectattr('name', 'equalto', runner_name) | first).status == 'offline'

- name: Unarchive runner package
ansible.builtin.unarchive:
src: "https://github.com/{{ runner_download_repository }}/releases/download/v{{ runner_version }}/\
Expand Down