diff --git a/action.yml b/action.yml index 87e15ebd..6ebcbd86 100644 --- a/action.yml +++ b/action.yml @@ -125,6 +125,10 @@ inputs: description: >- EC2 block device type. required: false + key-name: + description: >- + Key to use for the created EC2 instance + required: false outputs: label: diff --git a/dist/index.js b/dist/index.js index 4d59a0f4..9283abdf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -145021,7 +145021,9 @@ function buildUserDataScript(githubRegistrationToken, label) { '#!/bin/bash', 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1', `cd "${config.input.runnerHomeDir}"`, - `echo "${config.input.preRunnerScript}" > pre-runner-script.sh`, + `cat <<'EOF' > pre-runner-script.sh`, + config.input.preRunnerScript, + `EOF`, 'source pre-runner-script.sh', 'export RUNNER_ALLOW_RUNASROOT=1', `./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`, @@ -145031,7 +145033,9 @@ function buildUserDataScript(githubRegistrationToken, label) { '#!/bin/bash', 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1', 'mkdir actions-runner && cd actions-runner', - `echo "${config.input.preRunnerScript}" > pre-runner-script.sh`, + `cat <<'EOF' > pre-runner-script.sh`, + config.input.preRunnerScript, + `EOF`, 'source pre-runner-script.sh', 'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}', 'curl -O -L https://github.com/actions/runner/releases/download/v2.313.0/actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz', @@ -145083,6 +145087,7 @@ async function createEc2InstanceWithParams(imageId, subnetId, securityGroupId, l IamInstanceProfile: config.input.iamRoleName ? { Name: config.input.iamRoleName } : undefined, TagSpecifications: config.tagSpecifications, InstanceMarketOptions: buildMarketOptions(), + KeyName: config.input.keyName, }; if (config.input.ec2VolumeSize !== '' || config.input.ec2VolumeType !== '') { @@ -145235,6 +145240,7 @@ class Config { ec2VolumeType: core.getInput('ec2-volume-type'), blockDeviceMappings: JSON.parse(core.getInput('block-device-mappings') || '[]'), availabilityZonesConfig: core.getInput('availability-zones-config'), + keyName: core.getInput('key-name'), }; // Get the AWS_REGION environment variable diff --git a/src/aws.js b/src/aws.js index a5e309a3..fb23db35 100644 --- a/src/aws.js +++ b/src/aws.js @@ -13,7 +13,9 @@ function buildUserDataScript(githubRegistrationToken, label) { '#!/bin/bash', 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1', `cd "${config.input.runnerHomeDir}"`, - `echo "${config.input.preRunnerScript}" > pre-runner-script.sh`, + `cat <<'EOF' > pre-runner-script.sh`, + config.input.preRunnerScript, + `EOF`, 'source pre-runner-script.sh', 'export RUNNER_ALLOW_RUNASROOT=1', `./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`, @@ -23,7 +25,9 @@ function buildUserDataScript(githubRegistrationToken, label) { '#!/bin/bash', 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1', 'mkdir actions-runner && cd actions-runner', - `echo "${config.input.preRunnerScript}" > pre-runner-script.sh`, + `cat <<'EOF' > pre-runner-script.sh`, + config.input.preRunnerScript, + `EOF`, 'source pre-runner-script.sh', 'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}', 'curl -O -L https://github.com/actions/runner/releases/download/v2.313.0/actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz', @@ -75,6 +79,7 @@ async function createEc2InstanceWithParams(imageId, subnetId, securityGroupId, l IamInstanceProfile: config.input.iamRoleName ? { Name: config.input.iamRoleName } : undefined, TagSpecifications: config.tagSpecifications, InstanceMarketOptions: buildMarketOptions(), + KeyName: config.input.keyName, }; if (config.input.ec2VolumeSize !== '' || config.input.ec2VolumeType !== '') { diff --git a/src/config.js b/src/config.js index ab2f24fb..493ef9ae 100644 --- a/src/config.js +++ b/src/config.js @@ -26,6 +26,7 @@ class Config { ec2VolumeType: core.getInput('ec2-volume-type'), blockDeviceMappings: JSON.parse(core.getInput('block-device-mappings') || '[]'), availabilityZonesConfig: core.getInput('availability-zones-config'), + keyName: core.getInput('key-name'), }; // Get the AWS_REGION environment variable