Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'key-name' and 'block-device-mapping' options #156

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Now you're ready to go!
| `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). |
| `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> |
| `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>
<br><br> |
`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> |
| `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> ]
</pre>|

### Environment variables

Expand Down Expand Up @@ -263,6 +265,12 @@ jobs:
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
key-name: my-ssh-key # optional
block-device-mapper: | # optional
[
{"DeviceName" : "/dev/sda1", "Ebs" : { "VolumeType": "gp2", "VolumeSize": 34 }},
{"DeviceName" : "/dev/sdb", "VirtualName": "ephemeral0" }
]
do-the-job:
name: Do the job on the runner
needs: start-runner # required to start the main job when the runner is ready
Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ inputs:
description: >-
Specifies bash commands to run before the runner starts. It's useful for installing dependencies with apt-get, yum, dnf, etc.
required: false
block-device-mapping:
description: >-
JSON string of EC2 BlockDeviceMapping (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-blockdev-mapping.html).
required: false
default: '[]'
key-name:
description: >-
Assign SSH key-pair name to an instance. This can be useful for SSHing into an instance for debugging.
required: false

outputs:
label:
Expand Down
4 changes: 4 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62847,6 +62847,8 @@ async function startEc2Instance(label, githubRegistrationToken) {
SecurityGroupIds: [config.input.securityGroupId],
IamInstanceProfile: { Name: config.input.iamRoleName },
TagSpecifications: config.tagSpecifications,
BlockDeviceMappings: config.input.blockDeviceMappings,
KeyName: config.input.keyName,
};

try {
Expand Down Expand Up @@ -62923,6 +62925,8 @@ class Config {
iamRoleName: core.getInput('iam-role-name'),
runnerHomeDir: core.getInput('runner-home-dir'),
preRunnerScript: core.getInput('pre-runner-script'),
blockDeviceMappings: JSON.parse(core.getInput('block-device-mapping')),
keyName: core.getInput('key-name'),
};

const tags = JSON.parse(core.getInput('aws-resource-tags'));
Expand Down
2 changes: 2 additions & 0 deletions src/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ async function startEc2Instance(label, githubRegistrationToken) {
SecurityGroupIds: [config.input.securityGroupId],
IamInstanceProfile: { Name: config.input.iamRoleName },
TagSpecifications: config.tagSpecifications,
BlockDeviceMappings: config.input.blockDeviceMappings,
KeyName: config.input.keyName,
};

try {
Expand Down
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Config {
iamRoleName: core.getInput('iam-role-name'),
runnerHomeDir: core.getInput('runner-home-dir'),
preRunnerScript: core.getInput('pre-runner-script'),
blockDeviceMappings: JSON.parse(core.getInput('block-device-mapping')),
keyName: core.getInput('key-name'),
};

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