Skip to content

Commit 4a9d816

Browse files
committed
ansible: Create a default gh_app_id value of 0
When using organization-level runners, we use a GH app. That app has an ID and cert used to generate an ACCESS_TOKEN. When generating the runner's .service file, we check if the repo GH App matches any of the GH apps we have registered in out config. If so, an extra pre-run script is added to the start sequence. If a repository does not define the key "gh_app_id", our check would fail because the key is undefined. The trick here is that we set a GH app Id by default that does not exist, hence the check will never match, but it will not assert either. Long term, we should only support GH app and not PAT, so I am more inclined in using this as a middle step than properly supporting PAT and Apps. Signed-off-by: Manu Bretelle <[email protected]>
1 parent b4e2178 commit 4a9d816

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ansible/roles/runner/tasks/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@
4949
owner: root
5050
group: root
5151

52+
# Generate runners'facts by infering a normalized repo/org name from the repo name,
53+
# Generate a list of workers to generate, so we can easily iterate over that list.
54+
# Setting a default `gh_app_id` to 0. If `gh_app_id` is defined in the item, it will be
55+
# overriden by `combine(item)`, otherwise it will provide a "bogus" value that will never
56+
# match and actual GH app ID, but allows for the rest of the code to check for `gh_app_id`
57+
# vs checking its existence.
5258
- name: Generate runners facts
5359
set_fact:
54-
runners: "{{ runners|default([]) + [ {'normalized': item.name | replace('/','-'), 'workers': range(item.instances) | list } | combine(item) ] }}"
60+
runners: "{{ runners|default([]) + [ {'gh_app_id': 0, 'normalized': item.name | replace('/','-'), 'workers': range(item.instances) | list } | combine(item) ] }}"
5561
with_items: "{{ runner_repo_list }}"
5662

5763
- name: Generate runner environment file

0 commit comments

Comments
 (0)