Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 04feb32

Browse files
author
shimon
committed
move login from bash to puppet, add more info to readme, tag 0.1.2rc
1 parent f967a4d commit 04feb32

File tree

5 files changed

+59
-29
lines changed

5 files changed

+59
-29
lines changed

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
# GitHub Actions Runner
22

3-
This module is designed to auto configure all requirements to have the GitHub Actions runner ready to run on Debian hosts.
3+
This module is designed to automatically configure all requirements to have the GitHub Actions runner ready to run on Debian hosts as a service.
44

55
#### Table of Contents
66

77
1. [Description](#description)
8-
98
2. [Limitations - OS compatibility, etc.](#limitations)
109
3. [Development - Guide for contributing to the module](#development)
1110

12-
## Description
11+
### Description
12+
13+
This module will setup all of the files and configuration needed for GitHub Actions runner to work on any Debian 9 hosts.
14+
15+
16+
#### hiera configuration
1317

14-
This module will setup all of the file and configuration needed for GitHub Actions runner to work on any Debian host.
18+
This module supports configuration through hiera. The following example
19+
creates repository level Actions runners.
20+
```yaml
21+
github_actions_runner::ensure: present
22+
github_actions_runner::base_dir_name: '/data/actions-runner'
23+
github_actions_runner::package_name: 'actions-runner-linux-x64'
24+
github_actions_runner::package_ensure: '2.272.0'
25+
github_actions_runner::repository_url: 'https://github.com/actions/runner/releases/download'
26+
github_actions_runner::org_name: 'github_org'
27+
github_actions_runner::personal_access_token: 'PAT'
28+
github_actions_runner::user: 'root'
29+
github_actions_runner::group: 'root'
30+
github_actions_runner::labels:
31+
- self-hosted-custom
32+
```
1533
16-
## Limitations
34+
### Limitations
1735
1836
Tested on Debian 9 stretch hosts only.
19-
full operating systems support as describe in `metadata.json` file.
37+
full list of operating systems support and requirements are described in `metadata.json` file.
2038

2139

2240
If you don't specify repository name , make sure you `Personal Access Token` is org level admin.
2341

24-
## Development
42+
### Development
2543

2644
This module development should be just like any other puppet modules.

manifests/init.pp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@
6363

6464
$root_dir = "${github_actions_runner::base_dir_name}-${github_actions_runner::package_ensure}"
6565

66+
if $github_actions_runner::labels {
67+
$flattend_labels_list=join($github_actions_runner::labels, ',')
68+
$assured_labels="--labels ${flattend_labels_list}"
69+
}
70+
71+
if $github_actions_runner::repo_name {
72+
$url="https://github.com/${github_actions_runner::org_name}/${github_actions_runner::repo_name}"
73+
$token_url="https://api.github.com/repos/${github_actions_runner::org_name}/${github_actions_runner::repo_name}/actions/runners/registration-token"
74+
}
75+
else {
76+
$url="https://github.com/${github_actions_runner::org_name}"
77+
$token_url="https://api.github.com/repos/${github_actions_runner::org_name}/actions/runners/registration-token"
78+
}
79+
6680
class { '::github_actions_runner::config': }
6781
-> class { '::github_actions_runner::install': }
6882
~> class { '::github_actions_runner::service': }

metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "github_actions_runner",
3-
"version": "0.1.1",
2+
"name": "tuenti-github_actions_runner",
3+
"version": "0.1.2",
44
"author": "Shimon Ohayon",
55
"summary": "Module to configure our GitHub Actions runner on Debian hosts",
66
"license": "Apache-2.0",

spec/classes/github_actions_runner_spec.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,24 @@
5555
end
5656
end
5757

58-
context 'is expected to create a github_actions_runner installation script with content' do
58+
context 'is expected to create a github_actions_runner installation script with config in content' do
5959
it do
6060
is_expected.to contain_file('/tmp/actions-runner-1.0.1/configure_install_runner.sh').with_content(/\/tmp\/actions-runner-1.0.1\/config.sh/)
6161
end
6262
end
63+
64+
context 'is expected to create a github_actions_runner installation script with repo url in content' do
65+
it do
66+
is_expected.to contain_file('/tmp/actions-runner-1.0.1/configure_install_runner.sh').with_content(/https:\/\/github.com\/test_org\/test_repo/)
67+
end
68+
end
69+
70+
context 'is expected to create a github_actions_runner installation script with labels in content' do
71+
it do
72+
is_expected.to contain_file('/tmp/actions-runner-1.0.1/configure_install_runner.sh').with_content(/test_label1,test_label2/)
73+
end
74+
end
75+
6376
end
6477
end
6578
end

templates/configure_install_runner.sh.epp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,18 @@
22
# Configure the action runner after the package file has been downloaded.
33
set -e
44

5-
#Set URL's
6-
URL="https://github.com/<%= $github_actions_runner::org_name %>"
7-
TOKEN_URL="https://api.github.com/orgs/<%= $github_actions_runner::org_name %>/actions/runners/registration-token"
8-
9-
<% if $github_actions_runner::repo_name { -%>
10-
URL="https://github.com/<%= $github_actions_runner::org_name %>/<%= $github_actions_runner::repo_name %>"
11-
TOKEN_URL="https://api.github.com/repos/<%= $github_actions_runner::org_name %>/<%= $github_actions_runner::repo_name %>/actions/runners/registration-token"
12-
<% } -%>
13-
14-
# Set labels if defined
15-
<% if $github_actions_runner::labels { -%>
16-
LABELS="--labels <%= $github_actions_runner::labels.join(',') %>"
17-
<% } -%>
18-
195
# Get registration token.
206
TOKEN=$(curl -s -XPOST \
217
-H "authorization: token <%= $github_actions_runner::personal_access_token %>" \
22-
${TOKEN_URL} | jq -r .token)
8+
<%= $github_actions_runner::token_url %> | jq -r .token)
239

2410
# Allow root
2511
export RUNNER_ALLOW_RUNASROOT=true
2612

2713

28-
2914
# (Optional) Remove previous config.
3015
<%= $github_actions_runner::root_dir %>/config.sh remove \
31-
--url ${URL} \
16+
--url <%= $github_actions_runner::url %> \
3217
--token ${TOKEN} \
3318
--name <%= $github_actions_runner::hostname %> &>/dev/null
3419

@@ -38,9 +23,9 @@ export RUNNER_ALLOW_RUNASROOT=true
3823
--unattended \
3924
--replace \
4025
--name <%= $github_actions_runner::hostname %> \
41-
--url ${URL} \
26+
--url <%= $github_actions_runner::url %> \
4227
--token ${TOKEN} \
43-
${LABELS} &>/dev/null
28+
<%= $github_actions_runner::assured_labels %> &>/dev/null
4429

4530
# Copy service endpoint script.
4631
if [ ! -f <%= $github_actions_runner::root_dir %>/runsvc.sh ]; then

0 commit comments

Comments
 (0)