Skip to content

Commit fb9369b

Browse files
Merge pull request #58 from dverbeek84/develop
Add self hosted GitHub Enterprise support
2 parents e64ed4a + dc3e0a1 commit fb9369b

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ reinstall_runner: no
6666
hide_sensitive_logs: yes
6767

6868
# GitHub address
69-
github_server: "https://github.com"
69+
github_url: "https://github.com"
70+
71+
# GitHub API
72+
github_api_url: "https://api.github.com"
7073

7174
# Personal Access Token for your GitHub account
7275
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
@@ -77,6 +80,9 @@ runner_org: no
7780
# Name to assign to this runner in GitHub (System hostname as default)
7881
runner_name: "{{ ansible_hostname }}"
7982

83+
# Custom service name whe usign Github Enterprise server
84+
# service_name: actions.runner._services.{{ runner_name }}.service
85+
8086
# GitHub Repository user or Organization owner used for Runner registration
8187
# github_account: "youruser"
8288

defaults/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ reinstall_runner: no
2121
hide_sensitive_logs: yes
2222

2323
# GitHub address
24-
github_server: "https://github.com"
24+
github_url: "https://github.com"
25+
26+
# GitHub API
27+
github_api_url: "https://api.github.com"
2528

2629
# Personal Access Token for your GitHub account
2730
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
@@ -32,6 +35,9 @@ runner_org: no
3235
# Name to assign to this runner in GitHub (System hostname as default)
3336
runner_name: "{{ ansible_hostname }}"
3437

38+
# Custom service name whe usign Github Enterprise server
39+
# service_name: actions.runner._services.{{ runner_name }}.service
40+
3541
# GitHub Repository user or Organization owner used for Runner registration
3642
# github_account: "youruser"
3743

tasks/collect_info_org.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: Get registration token (RUN ONCE)
33
uri:
4-
url: "https://api.github.com/orgs/{{ github_owner | default(github_account) }}/actions/runners/registration-token"
4+
url: "{{ github_api_url }}/orgs/{{ github_owner | default(github_account) }}/actions/runners/registration-token"
55
headers:
66
Authorization: "token {{ access_token }}"
77
Accept: "application/vnd.github.v3+json"
@@ -16,7 +16,7 @@
1616

1717
- name: Check currently registered runners (RUN ONCE)
1818
uri:
19-
url: "https://api.github.com/orgs/{{ github_owner | default(github_account) }}/actions/runners"
19+
url: "{{ github_api_url }}/orgs/{{ github_owner | default(github_account) }}/actions/runners"
2020
headers:
2121
Authorization: "token {{ access_token }}"
2222
Accept: "application/vnd.github.v3+json"
@@ -38,6 +38,15 @@
3838
- name: Build service name
3939
set_fact:
4040
runner_service: "actions.runner.{{ (github_owner | default(github_account))[:45] }}.{{ runner_name }}.service"
41+
when: service_name is not defined
42+
tags:
43+
- install
44+
- uninstall
45+
46+
- name: Build service name
47+
set_fact:
48+
runner_service: "{{ service_name }}"
49+
when: service_name is defined
4150
tags:
4251
- install
4352
- uninstall

tasks/collect_info_repo.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: Get registration token (RUN ONCE)
33
uri:
4-
url: "https://api.github.com/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners/registration-token"
4+
url: "{{ github_api_url }}/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners/registration-token"
55
headers:
66
Authorization: "token {{ access_token }}"
77
Accept: "application/vnd.github.v3+json"
@@ -16,7 +16,7 @@
1616

1717
- name: Check currently registered runners (RUN ONCE)
1818
uri:
19-
url: "https://api.github.com/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners"
19+
url: "{{ github_api_url }}/repos/{{ github_owner | default(github_account) }}/{{ github_repo }}/actions/runners"
2020
headers:
2121
Authorization: "token {{ access_token }}"
2222
Accept: "application/vnd.github.v3+json"
@@ -45,6 +45,15 @@
4545
- name: Build service name
4646
set_fact:
4747
runner_service: "actions.runner.{{ svc_name[:45] }}.{{ runner_name }}.service"
48+
when: service_name is not defined
49+
tags:
50+
- install
51+
- uninstall
52+
53+
- name: Build service name
54+
set_fact:
55+
runner_service: "{{ service_name }}"
56+
when: service_name is defined
4857
tags:
4958
- install
5059
- uninstall

tasks/install_runner.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
uri:
1515
url: "https://api.github.com/repos/actions/runner/releases/latest"
1616
headers:
17-
Authorization: "token {{ access_token }}"
18-
Accept: "application/vnd.github.v3+json"
17+
Content-Type: "application/json"
1918
method: GET
20-
force_basic_auth: yes
2119
return_content: yes
2220
status_code: 200
2321
body_format: json

0 commit comments

Comments
 (0)