Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
193 lines (193 loc) · 7.97 KB
/
Copy pathaction.yml
File metadata and controls
193 lines (193 loc) · 7.97 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: "Ephemeral GCE GitHub self-hosted runner"
description: >-
Creates ephemeral GCE based GitHub Action self-hosted runner.
It uses startup script to bootstrap the VM.
author: Rafal Wojdyla
branding:
icon: triangle
color: purple
inputs:
token:
description: >-
GitHub auth token, needs `repo`/`public_repo` scope: https://docs.github.com/en/rest/reference/actions#self-hosted-runners.
required: true
project_id:
description: >-
ID of the Google Cloud Platform project. If provided, this will configure gcloud to use this project ID.
required: false
service_account_key:
description: >-
The service account key which will be used for authentication credentials.
This key should be created and stored as a secret. Should be JSON key.
required: false
runner_ver:
description: Version of the GitHub Runner. "latest" will resolve the latest version.
default: "latest"
required: true
machine_zone:
description: GCE zone
default: "us-central1-a"
required: true
machine_type:
description: GCE machine type; https://cloud.google.com/compute/docs/machine-types
default: "n1-standard-4"
required: true
disk_size:
description: VM disk size.
required: false
network:
description: Specifies the network that the VM instances are a part of.
required: false
subnet:
description: Specifies the subnet that the VM instances are a part of (must be part of network).
required: false
accelerator:
description: >
[count=COUNT],[type=TYPE]
Attaches accelerators (e.g. GPUs) to the instances.
TYPE
The specific type (e.g. nvidia-tesla-k80 for nVidia Tesla K80) of accelerator
to attach to the instances. Use 'gcloud compute accelerator-types list' to
learn about all available accelerator types.
COUNT
Number of accelerators to attach to each instance. The default value is 1.
required: false
runner_service_account:
description: Service account of the VM, defaults to default compute service account.
required: false
image_project:
description: >
The Google Cloud project against which all image and image family
references will be resolved.
required: false
image:
description: Specifies the name of the image that the disk will be initialized with.
required: false
image_family:
description: The image family for the operating system that the boot disk will be initialized with.
required: false
spot:
description: Use GCE Spot VM instance; https://cloud.google.com/compute/docs/instances/spot
default: false
required: true
ephemeral:
description: Set GitHub runner to be ephemeral; https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling
default: false
required: true
no_external_address:
description: Disables external IP address for the worker
default: false
required: true
scopes:
description: Scopes granted to the VM, defaults to full access (cloud-platform).
default: cloud-platform
required: true
shutdown_timeout:
description: "Shutdown grace period (in seconds)."
default: 30
required: true
actions_preinstalled:
description: "Whether the GitHub actions have already been installed at `/actions-runner`."
default: false
required: true
arm:
description: "Whether the GitHub actions should use arm64 binaries."
default: false
required: false
maintenance_policy_terminate:
description: "Set Google maintenance policy to TERMINATE. This is required for GPUs as they do ot support live-migration."
instance_termination_action:
description: >
Specifies action that will be taken upon Spot VM preemption or automatic instance termination
when the VM's current runtime reaches `max_run_duration`"
default: DELETE
required: true
boot_disk_type:
description: "Boot disk type for the GCE instance (https://cloud.google.com/sdk/gcloud/reference/compute/disk-types/list)"
required: false
max_run_duration:
description: >
Limits how long this VM instance can run, specified as a duration relative to the VM instance's most-recent start time."
Format the duration, as the number of days, hours, minutes, and seconds followed by d, h, m, and s respectively.
For example, specify 30m for a duration of 30 minutes or specify 1d2h3m4s for a duration of 1 day, 2 hours, 3 minutes, and 4 seconds.
default: "3d"
required: true
org_runner:
description: >
Register runner as org wide runner. Main benefit of using org wide runners is that it allows using fine-grained personal access token
with less privileges compared to repository runners.
default: true
required: true
vm_id_suffix:
description: Suffix to add to the VM ID. Useful when one job starts multiple runners and they are registered as org wide runners.
required: false
outputs:
label:
description: >-
Unique runner label. This label can be used to request a specific
runner for the workflow job.
value: ${{ steps.gce-github-runner-script.outputs.label }}
runs:
using: "composite"
steps:
- id: gce-github-runner-script
env:
ACTION_PATH: ${{ github.action_path }}
INPUT_TOKEN: ${{ inputs.token }}
INPUT_PROJECT_ID: ${{ inputs.project_id }}
INPUT_SERVICE_ACCOUNT_KEY: ${{ inputs.service_account_key }}
INPUT_RUNNER_VER: ${{ inputs.runner_ver }}
INPUT_MACHINE_ZONE: ${{ inputs.machine_zone }}
INPUT_MACHINE_TYPE: ${{ inputs.machine_type }}
INPUT_NETWORK: ${{ inputs.network }}
INPUT_SUBNET: ${{ inputs.subnet }}
INPUT_ACCELERATOR: ${{ inputs.accelerator }}
INPUT_DISK_SIZE: ${{ inputs.disk_size }}
INPUT_SCOPES: ${{ inputs.scopes }}
INPUT_SHUTDOWN_TIMEOUT: ${{ inputs.shutdown_timeout }}
INPUT_RUNNER_SERVICE_ACCOUNT: ${{ inputs.runner_service_account }}
INPUT_IMAGE_PROJECT: ${{ inputs.image_project }}
INPUT_IMAGE: ${{ inputs.image }}
INPUT_IMAGE_FAMILY: ${{ inputs.image_family }}
INPUT_BOOT_DISK_TYPE: ${{ inputs.boot_disk_type }}
INPUT_SPOT: ${{ inputs.spot }}
INPUT_EPHEMERAL: ${{ inputs.ephemeral }}
INPUT_NO_EXTERNAL_ADDRESS: ${{ inputs.no_external_address }}
INPUT_ACTIONS_PREINSTALLED: ${{ inputs.actions_preinstalled }}
INPUT_MAINTENANCE_POLICY_TERMINATE: ${{ inputs.maintenance_policy_terminate }}
INPUT_INSTANCE_TERMINATION_ACTION: ${{inputs.instance_termination_action}}
INPUT_ARM: ${{ inputs.arm }}
INPUT_MAX_RUN_DURATION: ${{inputs.max_run_duration}}
INPUT_ORG_RUNNER: ${{inputs.org_runner}}
INPUT_VM_ID_SUFFIX: ${{inputs.vm_id_suffix}}
run: >
$ACTION_PATH/action.sh
--command=start
--token=$INPUT_TOKEN
--project_id=$INPUT_PROJECT_ID
--service_account_key='$INPUT_SERVICE_ACCOUNT_KEY'
--runner_ver=$INPUT_RUNNER_VER
--machine_zone=$INPUT_MACHINE_ZONE
--machine_type=$INPUT_MACHINE_TYPE
--network=$INPUT_NETWORK
--subnet=$INPUT_SUBNET
--accelerator=$INPUT_ACCELERATOR
--disk_size=$INPUT_DISK_SIZE
--scopes=$INPUT_SCOPES
--shutdown_timeout=$INPUT_SHUTDOWN_TIMEOUT
--runner_service_account=$INPUT_RUNNER_SERVICE_ACCOUNT
--image_project=$INPUT_IMAGE_PROJECT
--image=$INPUT_IMAGE
--image_family=$INPUT_IMAGE_FAMILY
--boot_disk_type=$INPUT_BOOT_DISK_TYPE
--spot=$INPUT_SPOT
--ephemeral=$INPUT_EPHEMERAL
--no_external_address=$INPUT_NO_EXTERNAL_ADDRESS
--actions_preinstalled=$INPUT_ACTIONS_PREINSTALLED
--maintenance_policy_terminate=$INPUT_MAINTENANCE_POLICY_TERMINATE
--instance_termination_action=$INPUT_INSTANCE_TERMINATION_ACTION
--arm=$INPUT_ARM
--max_run_duration=$INPUT_MAX_RUN_DURATION
--org_runner=$INPUT_ORG_RUNNER
--vm_id_suffix=$INPUT_VM_ID_SUFFIX
shell: bash