Skip to content

Commit 3e4b87b

Browse files
feat: Add possiblity to set up access_token for pulling gh_actions release (#252)
At some cases, for example running github enterprise on-prem, we should be able to define token for the public github url which is used to pull the actions-runner latest release. This new variable defaults to access_token value if not set. Should be backward compatible for users using only public GH. Signed-off-by: Tibor Dudlák <Tibor.Dudlak@airbank.cz>
1 parent 436f45b commit 3e4b87b

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ It supports Enterprise, Organization and Repository Runners.
1515

1616
* The role requires a Personal Access Token to access GitHub. The token can be set as the `PERSONAL_ACCESS_TOKEN` environment variable.
1717

18-
> **Note**
18+
> **Note**
1919
> The token must have the `repo` scope (when creating a repo runner), the `admin:org` scope (when creating a runner for an organization),
2020
> or the `manage_runners:enterprise` scope (when creating an enterprise runner).
2121
> Personal Access Token for GitHub account can be created [here](https://github.com/settings/tokens).
2222
23-
> **Warning**
23+
> **Warning**
2424
> Never store your personal access token in the GitHub repository. Use [GitHub Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) or a different secrets service.
2525
2626
* Runner user has to be pre-created.
@@ -87,6 +87,9 @@ github_api_runners_per_page: 100
8787
# Personal Access Token for your GitHub account
8888
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
8989

90+
# Public github Access Token for the actions-runner release download
91+
public_gh_access_token: "{{ lookup('env', 'PUBLIC_GH_ACCESS_TOKEN') }}"
92+
9093
# Is it the runner for organization or not?
9194
runner_org: false
9295

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ github_api_runners_per_page: 100
2929
# Personal Access Token for your GitHub account
3030
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
3131

32+
# Public github Access Token for the actions-runner release download
33+
public_gh_access_token: "{{ lookup('env', 'PUBLIC_GH_ACCESS_TOKEN') }}"
34+
3235
# Is it the runner for organization or not?
3336
runner_org: false
3437

tasks/collect_info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
ansible.builtin.uri:
6565
url: "https://api.github.com/repos/{{ runner_download_repository }}/releases/latest"
6666
headers:
67-
Authorization: "token {{ access_token }}"
67+
Authorization: "token {{ public_gh_access_token | default(access_token) }}"
6868
Content-Type: "application/json"
6969
method: GET
7070
return_content: true

0 commit comments

Comments
 (0)