Skip to content

Commit

Permalink
Add option for custom root volume storage size
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Sep 25, 2024
1 parent fcfb31a commit 11d0042
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ 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>
| `storage-size` | Optional. Used only with the `start` mode. | Specifies the root volume size in GB. |
| `storage-device` | Optional. Used only with the `start` mode. | Specifies the volume device name to apply storage-size for. Defaults to `/dev/sda1`. |
<br><br> |

### Environment variables
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ 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
storage-size:
description: >-
Specifies the root volume size in GB.
required: false
storage-device:
description: >-
Specifies the volume device name to apply storage-size for. Defaults to /dev/sda1.
required: false

outputs:
label:
Expand Down
15 changes: 15 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65300,6 +65300,18 @@ async function startEc2Instance(label, githubRegistrationToken) {

const userData = buildUserDataScript(githubRegistrationToken, label);

const blockDeviceMappings = config.input.storageSize
? [
{
DeviceName: config.input.storageDevice ? config.input.storageDevice : '/dev/sda1',
Ebs: {
DeleteOnTermination: true,
VolumeSize: parseInt(config.input.storageSize),
},
},
]
: undefined;

const params = {
ImageId: config.input.ec2ImageId,
InstanceType: config.input.ec2InstanceType,
Expand All @@ -65310,6 +65322,7 @@ async function startEc2Instance(label, githubRegistrationToken) {
SecurityGroupIds: [config.input.securityGroupId],
IamInstanceProfile: { Name: config.input.iamRoleName },
TagSpecifications: config.tagSpecifications,
BlockDeviceMappings: blockDeviceMappings,
};

try {
Expand Down Expand Up @@ -65386,6 +65399,8 @@ class Config {
iamRoleName: core.getInput('iam-role-name'),
runnerHomeDir: core.getInput('runner-home-dir'),
preRunnerScript: core.getInput('pre-runner-script'),
storageSize: core.getInput('storage-size'),
storageDevice: core.getInput('storage-device'),
};

const tags = JSON.parse(core.getInput('aws-resource-tags'));
Expand Down
13 changes: 13 additions & 0 deletions src/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ async function startEc2Instance(label, githubRegistrationToken) {

const userData = buildUserDataScript(githubRegistrationToken, label);

const blockDeviceMappings = config.input.storageSize
? [
{
DeviceName: config.input.storageDevice ? config.input.storageDevice : '/dev/sda1',
Ebs: {
DeleteOnTermination: true,
VolumeSize: parseInt(config.input.storageSize),
},
},
]
: undefined;

const params = {
ImageId: config.input.ec2ImageId,
InstanceType: config.input.ec2InstanceType,
Expand All @@ -47,6 +59,7 @@ async function startEc2Instance(label, githubRegistrationToken) {
SecurityGroupIds: [config.input.securityGroupId],
IamInstanceProfile: { Name: config.input.iamRoleName },
TagSpecifications: config.tagSpecifications,
BlockDeviceMappings: blockDeviceMappings,
};

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'),
storageSize: core.getInput('storage-size'),
storageDevice: core.getInput('storage-device'),
};

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

0 comments on commit 11d0042

Please sign in to comment.