From 099577bec41c7a6f91eb31d3c36988c866fc5595 Mon Sep 17 00:00:00 2001 From: Ayodeji Fashola Date: Mon, 7 Mar 2022 12:13:19 +0100 Subject: [PATCH 1/2] add ebs block mapping feature --- README.md | 12 ++++++++++++ action.yml | 6 ++++++ src/aws.js | 1 + src/config.js | 1 + 4 files changed, 20 insertions(+) diff --git a/README.md b/README.md index c72dfcc1..e0ea723d 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,17 @@ Use the following steps to prepare your workflow for running on your EC2 self-ho 2. Add the keys to GitHub secrets. 3. Use the [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) action to set up the keys as environment variables. +4. You can also specify optional EBS mapping for tasks that utilizes more storage space. + `[ + { + "DeviceName": "/dev/sda1", + "Ebs": { + "DeleteOnTermination": true, + "VolumeSize": 40, + "VolumeType": "gp2" + } + } + ]` **2. Prepare GitHub personal access token** @@ -200,6 +211,7 @@ Now you're ready to go! | `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). | +| `block-device-mappings` | Optional. Use when more disk space is required | `[{ "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": true, "VolumeSize": 20, "VolumeType": "gp2"}}]` | | `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.

| diff --git a/action.yml b/action.yml index 0cea738b..e96803c5 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,12 @@ inputs: IAM Role Name to attach to the created EC2 instance. This requires additional permissions on the AWS role used to launch instances. required: false + block-device-mappings: + description: >- + EC2 instance ebs block device mapping + for example: '[{ "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": true, "VolumeSize": 20, "VolumeType": "gp2"}}]' + required: false + default: '[]' aws-resource-tags: description: >- Tags to attach to the launched EC2 instance and volume. diff --git a/src/aws.js b/src/aws.js index dea18e3f..e629edf6 100644 --- a/src/aws.js +++ b/src/aws.js @@ -43,6 +43,7 @@ async function startEc2Instance(label, githubRegistrationToken) { SecurityGroupIds: [config.input.securityGroupId], IamInstanceProfile: { Name: config.input.iamRoleName }, TagSpecifications: config.tagSpecifications, + BlockDeviceMappings: config.input.blockDeviceMappings, }; try { diff --git a/src/config.js b/src/config.js index 13bf86a1..808bad21 100644 --- a/src/config.js +++ b/src/config.js @@ -14,6 +14,7 @@ class Config { ec2InstanceId: core.getInput('ec2-instance-id'), iamRoleName: core.getInput('iam-role-name'), runnerHomeDir: core.getInput('runner-home-dir'), + blockDeviceMappings: JSON.parse(core.getInput('block-device-mappings')), }; const tags = JSON.parse(core.getInput('aws-resource-tags')); From 76574773f14161b01ebde6d9d4388331a832d21c Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 7 Mar 2022 11:17:57 +0000 Subject: [PATCH 2/2] Update dist --- dist/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index cc5bddde..79dd8aec 100644 --- a/dist/index.js +++ b/dist/index.js @@ -59432,6 +59432,7 @@ async function startEc2Instance(label, githubRegistrationToken) { SecurityGroupIds: [config.input.securityGroupId], IamInstanceProfile: { Name: config.input.iamRoleName }, TagSpecifications: config.tagSpecifications, + BlockDeviceMappings: config.input.blockDeviceMappings, }; try { @@ -59507,6 +59508,7 @@ class Config { ec2InstanceId: core.getInput('ec2-instance-id'), iamRoleName: core.getInput('iam-role-name'), runnerHomeDir: core.getInput('runner-home-dir'), + blockDeviceMappings: JSON.parse(core.getInput('block-device-mappings')), }; const tags = JSON.parse(core.getInput('aws-resource-tags'));