-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathaction.yml
More file actions
162 lines (158 loc) · 6.05 KB
/
action.yml
File metadata and controls
162 lines (158 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Self-Hosted GitHub Actions Runner on Hetzner Cloud
description: A GitHub Action to automatically create Hetzner Cloud servers and register them as self-hosted GitHub Actions runners.
author: Nils Knieling
branding:
icon: 'server'
color: 'red'
inputs:
create_wait:
description: >-
Wait up to 'create_wait' retries (10 sec each) to create the Server resource via the Hetzner Cloud API (default: 360 = 1 hour).
required: false
default: '360'
delete_wait:
description: >-
Wait up to 'delete_wait' retries (10 sec each) to delete the Server resource via the Hetzner Cloud API (default: 360 = 1 hour).
required: false
default: '360'
enable_ipv4:
description: >-
Attach an IPv4 on the public NIC (true/false) . If false, no IPv4 address will be attached.
Warning: The GitHub API requires IPv4. Disabling it will result in connection failures.
required: false
default: 'true'
enable_ipv6:
description: >-
Attach an IPv6 on the public NIC (true/false). If false, no IPv6 address will be attached.
required: false
default: 'true'
github_token:
description: >-
Fine-grained GitHub Personal Access Token (PAT) with 'Read and write' access to 'Administration' assigned.
required: true
hcloud_token:
description: >-
Hetzner Cloud API token with 'Read & Write' permissions assigned.
required: true
image:
description: >-
Name or ID (integer) of the Image the Server is created from.
required: false
default: 'ubuntu-24.04'
location:
description: >-
Name of Location to create Server in.
required: false
default: 'nbg1'
mode:
description: >-
Choose either 'create' to create a new GitHub Actions Runner or 'delete' to delete a previously created one.
required: true
name:
description: >-
The name for the server and label for the GitHub Actions Runner (must be unique within the project and conform to hostname rules: '[a-zA-Z0-9_-]').
required: false
network:
description: >-
Comma separated Network IDs (integer) which should be attached to the Server private network interface at the creation time.
required: false
default: 'null'
pre_runner_script:
description: >-
Specifies bash commands to run before the GitHub Actions Runner starts.
It's useful for installing dependencies with apt-get, dnf, zypper etc.
required: false
primary_ipv4:
description: >-
ID (integer) of the IPv4 Primary IP to use.
If omitted and 'enable_ipv4' is true, a new IPv4 Primary IP will automatically be created.
required: false
default: 'null'
primary_ipv6:
description: >-
ID (integer) of the IPv6 Primary IP to use.
If omitted and 'enable_ipv6' is true, a new IPv6 Primary IP will automatically be created.
required: false
default: 'null'
runner_dir:
description: >-
GitHub Actions Runner installation directory (created automatically; no trailing slash).
required: false
default: '/actions-runner'
runner_wait:
description: >-
Wait up to 'runner_wait' retries (10 sec each) for runner registration (default: 10 minutes).
required: false
default: '60'
runner_version:
description: >-
GitHub Actions Runner version (omit 'v'; e.g., '2.321.0').
'latest' will install the latest version.
'skip' will skip the installation. A working installation is expected in the 'runner_dir'.
required: false
default: 'latest'
server_id:
description: >-
ID (integer) of Hetzner Cloud Server to delete.
required: false
server_type:
description: >-
Name of the Server type this Server should be created with.
required: false
default: 'cx23'
server_wait:
description: >-
Wait up to 'server_wait' retries (10 sec each) for the Hetzner Cloud Server to start (default: 30 = 5 min).
required: false
default: '30'
ssh_key:
description: >-
Comma separated SSH key IDs (integer) which should be injected into the Server at creation time.
required: false
default: 'null'
volume:
description: >-
Comma separated Volume IDs (integer) which should be attached to the Server at the creation time.
required: false
default: 'null'
outputs:
label:
description: >-
This label uniquely identifies a GitHub Actions runner,
used both to specify which runner a job should execute on via the `runs-on` property and to delete the runner when it's no longer needed.
value: ${{ steps.hcloud-github-runner.outputs.label }}
server_id:
description: >-
This is the Hetzner Cloud server ID of the runner, used to delete the server when the runner is no longer required.
value: ${{ steps.hcloud-github-runner.outputs.server_id }}
runs:
using: "composite"
steps:
- name: GitHub Actions Runner in Hetzner Cloud
id: hcloud-github-runner
shell: bash
working-directory: ${{ github.action_path }}
run: bash action.sh
env:
INPUT_CREATE_WAIT: ${{ inputs.create_wait }}
INPUT_DELETE_WAIT: ${{ inputs.delete_wait }}
INPUT_ENABLE_IPV4: ${{ inputs.enable_ipv4 }}
INPUT_ENABLE_IPV6: ${{ inputs.enable_ipv6 }}
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_HCLOUD_TOKEN: ${{ inputs.hcloud_token }}
INPUT_IMAGE: ${{ inputs.image }}
INPUT_LOCATION: ${{ inputs.location }}
INPUT_MODE: ${{ inputs.mode }}
INPUT_NAME: ${{ inputs.name }}
INPUT_NETWORKS: ${{ inputs.network }}
INPUT_PRE_RUNNER_SCRIPT: ${{ inputs.pre_runner_script }}
INPUT_PRIMARY_IPV4: ${{ inputs.primary_ipv4 }}
INPUT_PRIMARY_IPV6: ${{ inputs.primary_ipv6 }}
INPUT_RUNNER_DIR: ${{ inputs.runner_dir }}
INPUT_RUNNER_VERSION: ${{ inputs.runner_version }}
INPUT_RUNNER_WAIT: ${{ inputs.runner_wait }}
INPUT_SERVER_ID: ${{ inputs.server_id }}
INPUT_SERVER_TYPE: ${{ inputs.server_type }}
INPUT_SERVER_WAIT: ${{ inputs.server_wait }}
INPUT_SSH_KEYS: ${{ inputs.ssh_key }}
INPUT_VOLUMES: ${{ inputs.volume }}