Skip to content

Commit e22611f

Browse files
committed
Revert "Revert "Add 'key-name' and 'block-device-mapping' options (machulav#156)""
This reverts commit 6bf1bac.
1 parent 6bf1bac commit e22611f

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ Now you're ready to go!
206206
| `aws-resource-tags` | Optional. Used only with the `start` mode. | Specifies tags to add to the EC2 instance and any attached storage. <br><br> This field is a stringified JSON array of tag objects, each containing a `Key` and `Value` field (see example below). <br><br> Setting this requires additional AWS permissions for the role launching the instance (see above). |
207207
| `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> |
208208
| `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>
209-
<br><br> |
209+
`key-name` | Optional. Used only with the `start` mode. | Specifies SSH key-pair name to assign to an instance. This is useful for SSHing into an instance for debugging.<br><br> |
210+
| `block-device-mapping` | Optional. Used only with the `start` mode. | JSON string specifying the [BlockDeviceMapping](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-blockdev-mapping.html). For example:<pre> block-device-mapper: \|<br> [<br> {"DeviceName" : "/dev/sda1", "Ebs" : { "VolumeType": "gp2", "VolumeSize": 34 }},<br> {"DeviceName" : "/dev/sdb", "VirtualName": "ephemeral0" }<br> ]
211+
</pre>|
210212

211213
### Environment variables
212214

@@ -263,6 +265,12 @@ jobs:
263265
{"Key": "Name", "Value": "ec2-github-runner"},
264266
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
265267
]
268+
key-name: my-ssh-key # optional
269+
block-device-mapper: | # optional
270+
[
271+
{"DeviceName" : "/dev/sda1", "Ebs" : { "VolumeType": "gp2", "VolumeSize": 34 }},
272+
{"DeviceName" : "/dev/sdb", "VirtualName": "ephemeral0" }
273+
]
266274
do-the-job:
267275
name: Do the job on the runner
268276
needs: start-runner # required to start the main job when the runner is ready

action.yml

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ inputs:
6969
description: >-
7070
Specifies bash commands to run before the runner starts. It's useful for installing dependencies with apt-get, yum, dnf, etc.
7171
required: false
72+
block-device-mapping:
73+
description: >-
74+
JSON string of EC2 BlockDeviceMapping (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-blockdev-mapping.html).
75+
required: false
76+
default: '[]'
77+
key-name:
78+
description: >-
79+
Assign SSH key-pair name to an instance. This can be useful for SSHing into an instance for debugging.
80+
required: false
7281

7382
outputs:
7483
label:

dist/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -62847,6 +62847,8 @@ async function startEc2Instance(label, githubRegistrationToken) {
6284762847
SecurityGroupIds: [config.input.securityGroupId],
6284862848
IamInstanceProfile: { Name: config.input.iamRoleName },
6284962849
TagSpecifications: config.tagSpecifications,
62850+
BlockDeviceMappings: config.input.blockDeviceMappings,
62851+
KeyName: config.input.keyName,
6285062852
};
6285162853

6285262854
try {
@@ -62923,6 +62925,8 @@ class Config {
6292362925
iamRoleName: core.getInput('iam-role-name'),
6292462926
runnerHomeDir: core.getInput('runner-home-dir'),
6292562927
preRunnerScript: core.getInput('pre-runner-script'),
62928+
blockDeviceMappings: JSON.parse(core.getInput('block-device-mapping')),
62929+
keyName: core.getInput('key-name'),
6292662930
};
6292762931

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

src/aws.js

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ async function startEc2Instance(label, githubRegistrationToken) {
5050
SecurityGroupIds: [config.input.securityGroupId],
5151
IamInstanceProfile: { Name: config.input.iamRoleName },
5252
TagSpecifications: config.tagSpecifications,
53+
BlockDeviceMappings: config.input.blockDeviceMappings,
54+
KeyName: config.input.keyName,
5355
};
5456

5557
try {

src/config.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class Config {
1515
iamRoleName: core.getInput('iam-role-name'),
1616
runnerHomeDir: core.getInput('runner-home-dir'),
1717
preRunnerScript: core.getInput('pre-runner-script'),
18+
blockDeviceMappings: JSON.parse(core.getInput('block-device-mapping')),
19+
keyName: core.getInput('key-name'),
1820
};
1921

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

0 commit comments

Comments
 (0)