From d5283bdf1361f0565aab378a23107f902eda295d Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Tue, 4 Mar 2025 17:46:06 -0500 Subject: [PATCH 1/5] Replay changes from i-dot-ai:feature/add-optional-volume-size --- .env.example | 1 + README.md | 1 + action.yml | 4 ++++ dist/index.js | 11 +++++++++++ src/aws.js | 10 ++++++++++ src/config.js | 1 + 6 files changed, 28 insertions(+) diff --git a/.env.example b/.env.example index 2db35299..12028dcf 100644 --- a/.env.example +++ b/.env.example @@ -19,3 +19,4 @@ INPUT_SECURITY-GROUP-ID= INPUT_LABEL= INPUT_EC2-INSTANCE-ID= GITHUB_REPOSITORY= +INPUT_EC2-VOLUME-SIZE= \ No newline at end of file diff --git a/README.md b/README.md index 19748696..e0b275c5 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,7 @@ Now you're ready to go! | `runner-home-dir` | Optional. Used only with the `start` mode. | Specifies a directory where pre-installed actions-runner software and scripts are located.

| | `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:
          - name: Start EC2 runner
with:
mode: start
...
pre-runner-script: \|
sudo yum update -y && \
sudo yum install docker git libicu -y
sudo systemctl enable docker
| | `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. | +| `ec2-volume-size` | Optional. | Defines the size of the EC2 Volume in GB, will use the AWS default of 16 GB if not provided. | ### Environment variables diff --git a/action.yml b/action.yml index d3f1d9f5..0c6ad94a 100644 --- a/action.yml +++ b/action.yml @@ -74,6 +74,10 @@ inputs: Specifies the market (purchasing) option for the instance: - 'spot' - Use a spot instance required: false + ec2-volume-size: + description: >- + Defines the size of the EC2 Volume in GB, will use the AWS default of 16 GB if not provided. + required: false outputs: label: diff --git a/dist/index.js b/dist/index.js index fbaaa406..5634edc0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -148426,6 +148426,16 @@ async function startEc2Instance(label, githubRegistrationToken) { IamInstanceProfile: { Name: config.input.iamRoleName }, TagSpecifications: config.tagSpecifications, InstanceMarketOptions: buildMarketOptions(), + ...config.input.ec2VolumeSize && { + BlockDeviceMappings: [ + { + DeviceName: "/dev/sda1", + Ebs: { + VolumeSize: config.input.ec2VolumeSize + } + } + ] + }, }; try { @@ -148513,6 +148523,7 @@ class Config { runnerHomeDir: core.getInput('runner-home-dir'), preRunnerScript: core.getInput('pre-runner-script'), marketType: core.getInput('market-type'), + ec2VolumeSize: core.getInput('ec2-volume-size'), }; const tags = JSON.parse(core.getInput('aws-resource-tags')); diff --git a/src/aws.js b/src/aws.js index ac83394a..c028cbe1 100644 --- a/src/aws.js +++ b/src/aws.js @@ -62,6 +62,16 @@ async function startEc2Instance(label, githubRegistrationToken) { IamInstanceProfile: { Name: config.input.iamRoleName }, TagSpecifications: config.tagSpecifications, InstanceMarketOptions: buildMarketOptions(), + ...config.input.ec2VolumeSize && { + BlockDeviceMappings: [ + { + DeviceName: "/dev/sda1", + Ebs: { + VolumeSize: config.input.ec2VolumeSize + } + } + ] + }, }; try { diff --git a/src/config.js b/src/config.js index b8bbc4fc..07cc67c4 100644 --- a/src/config.js +++ b/src/config.js @@ -16,6 +16,7 @@ class Config { runnerHomeDir: core.getInput('runner-home-dir'), preRunnerScript: core.getInput('pre-runner-script'), marketType: core.getInput('market-type'), + ec2VolumeSize: core.getInput('ec2-volume-size'), }; const tags = JSON.parse(core.getInput('aws-resource-tags')); From 57a6dc1fda33a8ac04570224cc5d0ca68743c3bb Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Wed, 5 Mar 2025 14:55:55 -0500 Subject: [PATCH 2/5] Add device name --- action.yml | 8 +++++++- src/aws.js | 18 ++++++++---------- src/config.js | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 0c6ad94a..b301431e 100644 --- a/action.yml +++ b/action.yml @@ -76,7 +76,13 @@ inputs: required: false ec2-volume-size: description: >- - Defines the size of the EC2 Volume in GB, will use the AWS default of 16 GB if not provided. + EC2 volume size in GB. + default: "8" + required: false + ec2-device-name: + description: >- + EC2 block device name. + default: /dev/sda1 required: false outputs: diff --git a/src/aws.js b/src/aws.js index c028cbe1..552d22af 100644 --- a/src/aws.js +++ b/src/aws.js @@ -62,16 +62,14 @@ async function startEc2Instance(label, githubRegistrationToken) { IamInstanceProfile: { Name: config.input.iamRoleName }, TagSpecifications: config.tagSpecifications, InstanceMarketOptions: buildMarketOptions(), - ...config.input.ec2VolumeSize && { - BlockDeviceMappings: [ - { - DeviceName: "/dev/sda1", - Ebs: { - VolumeSize: config.input.ec2VolumeSize - } - } - ] - }, + BlockDeviceMappings: [ + { + DeviceName: config.input.ec2DeviceName, + Ebs: { + VolumeSize: config.input.ec2VolumeSize, + }, + }, + ], }; try { diff --git a/src/config.js b/src/config.js index 07cc67c4..8a886654 100644 --- a/src/config.js +++ b/src/config.js @@ -17,6 +17,7 @@ class Config { preRunnerScript: core.getInput('pre-runner-script'), marketType: core.getInput('market-type'), ec2VolumeSize: core.getInput('ec2-volume-size'), + ec2DeviceName: core.getInput('ec2-device-name'), }; const tags = JSON.parse(core.getInput('aws-resource-tags')); From 986493ae0b5230c6e0587107130c600eddce13f8 Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Wed, 5 Mar 2025 14:57:04 -0500 Subject: [PATCH 3/5] Add device name --- .env.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 12028dcf..42151e51 100644 --- a/.env.example +++ b/.env.example @@ -19,4 +19,5 @@ INPUT_SECURITY-GROUP-ID= INPUT_LABEL= INPUT_EC2-INSTANCE-ID= GITHUB_REPOSITORY= -INPUT_EC2-VOLUME-SIZE= \ No newline at end of file +INPUT_EC2-VOLUME-SIZE= +INPUT_EC2-DEVICE-NAME= \ No newline at end of file From 929ac8605a99ab67ba52bae18a230436432706ab Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Wed, 5 Mar 2025 14:57:36 -0500 Subject: [PATCH 4/5] Package up --- .env.example | 2 +- dist/index.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index 42151e51..0aab5b1a 100644 --- a/.env.example +++ b/.env.example @@ -20,4 +20,4 @@ INPUT_LABEL= INPUT_EC2-INSTANCE-ID= GITHUB_REPOSITORY= INPUT_EC2-VOLUME-SIZE= -INPUT_EC2-DEVICE-NAME= \ No newline at end of file +INPUT_EC2-DEVICE-NAME= diff --git a/dist/index.js b/dist/index.js index 5634edc0..344091c2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -148426,16 +148426,14 @@ async function startEc2Instance(label, githubRegistrationToken) { IamInstanceProfile: { Name: config.input.iamRoleName }, TagSpecifications: config.tagSpecifications, InstanceMarketOptions: buildMarketOptions(), - ...config.input.ec2VolumeSize && { - BlockDeviceMappings: [ - { - DeviceName: "/dev/sda1", - Ebs: { - VolumeSize: config.input.ec2VolumeSize - } - } - ] - }, + BlockDeviceMappings: [ + { + DeviceName: config.input.ec2DeviceName, + Ebs: { + VolumeSize: config.input.ec2VolumeSize, + }, + }, + ], }; try { @@ -148524,6 +148522,7 @@ class Config { preRunnerScript: core.getInput('pre-runner-script'), marketType: core.getInput('market-type'), ec2VolumeSize: core.getInput('ec2-volume-size'), + ec2DeviceName: core.getInput('ec2-device-name'), }; const tags = JSON.parse(core.getInput('aws-resource-tags')); From 97328aea29a7b1da7f840fd9434b3046dfcc07a9 Mon Sep 17 00:00:00 2001 From: Devin Zuczek Date: Wed, 5 Mar 2025 14:58:41 -0500 Subject: [PATCH 5/5] Update readme --- README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e0b275c5..6a037156 100644 --- a/README.md +++ b/README.md @@ -202,22 +202,23 @@ Now you're ready to go! ### Inputs -|               Name               | Required | Description | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `mode` | Always required. | Specify here which mode you want to use:
- `start` - to start a new runner;
- `stop` - to stop the previously created runner. | -| `github-token` | Always required. | GitHub Personal Access Token with the `repo` scope assigned. | -| `ec2-image-id` | Required if you use the `start` mode. | EC2 Image Id (AMI).

The new runner will be launched from this image.

The action is compatible with Amazon Linux 2 images. | -| `ec2-instance-type` | Required if you use the `start` mode. | EC2 Instance Type. | -| `subnet-id` | Required if you use the `start` mode. | VPC Subnet Id.

The subnet should belong to the same VPC as the specified security group. | -| `security-group-id` | Required if you use the `start` mode. | EC2 Security Group Id.

The security group should belong to the same VPC as the specified subnet.

Only the outbound traffic for port 443 should be allowed. No inbound traffic is required. | -| `label` | Required if you use the `stop` mode. | Name of the unique label assigned to the runner.

The label is provided by the output of the action in the `start` mode.

The label is used to remove the runner from GitHub when the runner is not needed anymore. | -| `ec2-instance-id` | Required if you use the `stop` mode. | EC2 Instance Id of the created runner.

The id is provided by the output of the action in the `start` mode.

The id is used to terminate the EC2 instance when the runner is not needed anymore. | -| `iam-role-name` | Optional. Used only with the `start` mode. | IAM role name to attach to the created EC2 runner.

This allows the runner to have permissions to run additional actions within the AWS account, without having to manage additional GitHub secrets and AWS users.

Setting this requires additional AWS permissions for the role launching the instance (see above). | -| `aws-resource-tags` | Optional. Used only with the `start` mode. | Specifies tags to add to the EC2 instance and any attached storage.

This field is a stringified JSON array of tag objects, each containing a `Key` and `Value` field (see example below).

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.

| -| `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:
          - name: Start EC2 runner
with:
mode: start
...
pre-runner-script: \|
sudo yum update -y && \
sudo yum install docker git libicu -y
sudo systemctl enable docker
| -| `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. | -| `ec2-volume-size` | Optional. | Defines the size of the EC2 Volume in GB, will use the AWS default of 16 GB if not provided. | +|               Name               | Required | Description | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `mode` | Always required. | Specify here which mode you want to use:
- `start` - to start a new runner;
- `stop` - to stop the previously created runner. | +| `github-token` | Always required. | GitHub Personal Access Token with the `repo` scope assigned. | +| `ec2-image-id` | Required if you use the `start` mode. | EC2 Image Id (AMI).

The new runner will be launched from this image.

The action is compatible with Amazon Linux 2 images. | +| `ec2-instance-type` | Required if you use the `start` mode. | EC2 Instance Type. | +| `subnet-id` | Required if you use the `start` mode. | VPC Subnet Id.

The subnet should belong to the same VPC as the specified security group. | +| `security-group-id` | Required if you use the `start` mode. | EC2 Security Group Id.

The security group should belong to the same VPC as the specified subnet.

Only the outbound traffic for port 443 should be allowed. No inbound traffic is required. | +| `label` | Required if you use the `stop` mode. | Name of the unique label assigned to the runner.

The label is provided by the output of the action in the `start` mode.

The label is used to remove the runner from GitHub when the runner is not needed anymore. | +| `ec2-instance-id` | Required if you use the `stop` mode. | EC2 Instance Id of the created runner.

The id is provided by the output of the action in the `start` mode.

The id is used to terminate the EC2 instance when the runner is not needed anymore. | +| `iam-role-name` | Optional. Used only with the `start` mode. | IAM role name to attach to the created EC2 runner.

This allows the runner to have permissions to run additional actions within the AWS account, without having to manage additional GitHub secrets and AWS users.

Setting this requires additional AWS permissions for the role launching the instance (see above). | +| `aws-resource-tags` | Optional. Used only with the `start` mode. | Specifies tags to add to the EC2 instance and any attached storage.

This field is a stringified JSON array of tag objects, each containing a `Key` and `Value` field (see example below).

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.

| +| `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:
          - name: Start EC2 runner
with:
mode: start
...
pre-runner-script: \|
sudo yum update -y && \
sudo yum install docker git libicu -y
sudo systemctl enable docker
| +| `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. | +| `ec2-volume-size` | Optional. | Defines the size of the EC2 Volume in GB, will use the AWS default of 8 GB if not provided. | +| `ec2-device-name` | Optional. | Defines the device name used for the root volume. | ### Environment variables