Skip to content

Commit ed4b47a

Browse files
Merge pull request #234 from rickyn-croesus/dev/cp-5427
Force reinstallation when self-hosted Runner is not installed but is registered with Github Runners.
2 parents c7ced19 + fde769a commit ed4b47a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tasks/collect_info.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,11 @@
3333

3434
- name: "Check currently registered runners for repo {{ '(RUN ONCE)' if all_runners_in_same_repo else '' }}"
3535
ansible.builtin.uri:
36-
url: "{{ github_full_api_url }}"
36+
url: "{{ github_full_api_url }}{{ '?' if '?' not in github_full_api_url else '&' }}per_page={{ github_api_runners_per_page }}"
3737
headers:
3838
Authorization: "token {{ access_token }}"
3939
Accept: "application/vnd.github.v3+json"
4040
method: GET
41-
body_format: form-urlencoded
42-
body:
43-
per_page: "{{ github_api_runners_per_page }}"
4441
status_code: 200
4542
force_basic_auth: true
4643
register: registered_runners

tasks/install_runner_unix.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
changed_when: false
2020
ignore_errors: true
2121

22+
- name: Force reinstall if runner {{ runner_name }} in registered_runners is offline (meaning the self-hosted runner is not tied to the Github runner)
23+
ansible.builtin.set_fact:
24+
reinstall_runner: true
25+
when:
26+
- not reinstall_runner
27+
- runner_name in (registered_runners.json.runners | map(attribute='name') | list)
28+
- (registered_runners.json.runners | selectattr('name', 'equalto', runner_name) | first).status == 'offline'
29+
2230
- name: Unarchive runner package
2331
ansible.builtin.unarchive:
2432
src: "https://github.com/{{ runner_download_repository }}/releases/download/v{{ runner_version }}/\

0 commit comments

Comments
 (0)