Skip to content

Commit 13997d4

Browse files
Merge pull request #1 from MonolithProjects/develop
Added registration token request
2 parents 5a2d54d + 4af2a43 commit 13997d4

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This role will deploy local GitHub Actions Runner.
1111
The role is in early development stage.
1212
Role is able to:
1313
- install and cofigure local runner
14+
- request reistration token
1415
- register the runner to GitHub
1516

1617
Currently is missing:
@@ -25,7 +26,7 @@ System must have access to the packages repository (Internet, Red Hat Satellite,
2526

2627
CentOS/Fedora systems require EPEL repository.
2728

28-
`GITHUB_ACCESS_TOKEN` variable needs to be exported to your environment.
29+
`PERSONAL_ACCESS_TOKEN` variable needs to be exported to your environment.
2930

3031
Role Variables
3132
--------------
@@ -39,17 +40,17 @@ runner_dir: "/opt/actions-runner"
3940
# Version of the GitHub Actions Runner
4041
runner_version: "2.165.2"
4142

42-
# GitHub Access token for the repository
43-
access_token: "{{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
43+
# Personal Access Token for your GitHub account
44+
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
4445

4546
# GitHub address
4647
github_server: "https://github.com"
4748

4849
# GitHub account name
49-
# github_account: "yourgithubname"
50+
# github_account: "youruser"
5051

5152
# Github repository name
52-
# github_repo: "yourreponame"
53+
# github_repo: "yourrepo"
5354
```
5455

5556
Example Playbook
@@ -65,9 +66,9 @@ Simple example.
6566
vars:
6667
- runner_user: runner
6768
- github_account: example
68-
- github_repo: example"
69+
- github_repo: example
6970
roles:
70-
- role: ansible-github_actions_runner
71+
- role: monolithprojects/github_actions_runner
7172
```
7273
7374
License

defaults/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ runner_dir: "/opt/actions-runner"
55
# Version of the GitHub Actions Runner
66
runner_version: "2.165.2"
77

8-
# GitHub Access token for the repository
9-
access_token: "{{ lookup('env', 'GITHUB_ACCESS_TOKEN') }}"
8+
# Personal Access Token for your GitHub account
9+
access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
1010

1111
# GitHub address
1212
github_server: "https://github.com"

tasks/install_runner.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
tags:
2828
- install
2929

30+
- name: Get registration token
31+
uri:
32+
url: "https://api.github.com/repos/{{ github_account }}/{{ github_repo }}/actions/runners/registration-token"
33+
user: "{{ github_account }}"
34+
password: "{{ access_token }}"
35+
method: POST
36+
status_code: 201
37+
force_basic_auth: yes
38+
register: registration
39+
run_once: yes
40+
tags:
41+
- install
42+
- uninstall
43+
3044
# - name: Sstop and disable Github Actions Runner service if it is running
3145
# systemd:
3246
# name: "actions.runner.{{ github_account }}-{{ github_repo }}.{{ ansible_hostname }}"
@@ -36,13 +50,13 @@
3650
# - uninstall
3751

3852
# - name: Unregister runner
39-
# command: "{{ runner_dir }}/./config.sh remove --token {{ access_token }} --unattended"
53+
# command: "{{ runner_dir }}/./config.sh remove --token {{ registration.json.token }} --unattended"
4054
# become_user: "{{ runner_user }}"
4155
# tags:
4256
# - uninstall
4357

4458
- name: Register runner
45-
command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ access_token }} --unattended"
59+
command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} --token {{ registration.json.token }} --unattended"
4660
become_user: "{{ runner_user }}"
4761
tags:
4862
- install

0 commit comments

Comments
 (0)