Skip to content

Commit 62d2101

Browse files
authored
add new block-device-mappings parameter (machulav#229)
This allows the user to specify the settings on the node's underlying EBS volume. For example, the user can change the thoroughput on the volume.
1 parent cd07fa6 commit 62d2101

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ Now you're ready to go!
217217
| `runner-home-dir` | Optional. Used only with the `start` mode. | Specifies a directory where pre-installed actions-runner software and scripts are located.<br><br> |
218218
| `pre-runner-script` | Optional. Used only with the `start` mode. | Specifies bash commands to run before the runner starts. It's useful for installing dependencies with apt-get, yum, dnf, etc. For example:<pre> - name: Start EC2 runner<br> with:<br> mode: start<br> ...<br> pre-runner-script: \|<br> sudo yum update -y && \ <br> sudo yum install docker git libicu -y<br> sudo systemctl enable docker</pre> |
219219
| `market-type` | Optional. Used only with the `start` mode. | The only valid option is `spot`. If `spot` is specified, a Spot instance will be requested. If left unspecified, an on-demand instance will be provisioned. |
220+
| `block-device-mappings` | Optional. Used only with the `start` mode. | JSON string specifying the block device mappings for the EC2 instance. For example: <br> <pre>[{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 100, "VolumeType": "gp3"}}]</pre> See <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html">AWS BlockDeviceMapping docs</a> for all options. |
220221
| `startup-quiet-period-seconds` | Optional | Default: 30 |
221222
| `startup-retry-interval-seconds` | Optional | Default: 10 |
222223
| `startup-timeout-minutes` | Optional | Default: 5 |
@@ -276,6 +277,10 @@ jobs:
276277
{"Key": "Name", "Value": "ec2-github-runner"},
277278
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
278279
]
280+
block-device-mappings: > # optional, to customize EBS volumes
281+
[
282+
{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 100, "VolumeType": "gp3"}}
283+
]
279284
do-the-job:
280285
name: Do the job on the runner
281286
needs: start-runner # required to start the main job when the runner is ready

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ inputs:
7474
Specifies the market (purchasing) option for the instance:
7575
- 'spot' - Use a spot instance
7676
required: false
77+
block-device-mappings:
78+
description: >-
79+
JSON string specifying the block device mappings for the EC2 instance.
80+
Example: '[{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 100, "VolumeType": "gp3"}}]'
81+
required: false
7782
startup-quiet-period-seconds:
7883
description: >-
7984
Specifies the quiet period in seconds after the instance starts.

dist/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145083,6 +145083,10 @@ async function startEc2Instance(label, githubRegistrationToken) {
145083145083
InstanceMarketOptions: buildMarketOptions(),
145084145084
};
145085145085

145086+
if (config.input.blockDeviceMappings.length > 0) {
145087+
params.BlockDeviceMappings = config.input.blockDeviceMappings;
145088+
}
145089+
145086145090
try {
145087145091
const result = await ec2.send(new RunInstancesCommand(params));
145088145092
const ec2InstanceId = result.Instances[0].InstanceId;
@@ -145172,7 +145176,8 @@ class Config {
145172145176
startupTimeoutMinutes: core.getInput('startup-timeout-minutes'),
145173145177
subnetId: core.getInput('subnet-id'),
145174145178
runAsService: core.getInput('run-runner-as-service') === 'true',
145175-
runAsUser: core.getInput('run-runner-as-user')
145179+
runAsUser: core.getInput('run-runner-as-user'),
145180+
blockDeviceMappings: JSON.parse(core.getInput('block-device-mappings') || '[]')
145176145181
};
145177145182

145178145183
const tags = JSON.parse(core.getInput('aws-resource-tags'));

src/aws.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ async function startEc2Instance(label, githubRegistrationToken) {
7575
InstanceMarketOptions: buildMarketOptions(),
7676
};
7777

78+
if (config.input.blockDeviceMappings.length > 0) {
79+
params.BlockDeviceMappings = config.input.blockDeviceMappings;
80+
}
81+
7882
try {
7983
const result = await ec2.send(new RunInstancesCommand(params));
8084
const ec2InstanceId = result.Instances[0].InstanceId;

src/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class Config {
2020
startupTimeoutMinutes: core.getInput('startup-timeout-minutes'),
2121
subnetId: core.getInput('subnet-id'),
2222
runAsService: core.getInput('run-runner-as-service') === 'true',
23-
runAsUser: core.getInput('run-runner-as-user')
23+
runAsUser: core.getInput('run-runner-as-user'),
24+
blockDeviceMappings: JSON.parse(core.getInput('block-device-mappings') || '[]')
2425
};
2526

2627
const tags = JSON.parse(core.getInput('aws-resource-tags'));

0 commit comments

Comments
 (0)