Skip to content

Commit d92e65e

Browse files
committed
Dropped ec2- prefix on inputs and outputs
1 parent 23b282e commit d92e65e

File tree

8 files changed

+77
-74
lines changed

8 files changed

+77
-74
lines changed

.env.example

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ AWS_ACCESS_KEY_ID=
1212
AWS_SECRET_ACCESS_KEY=
1313
INPUT_MODE=
1414
INPUT_GITHUB-TOKEN=
15-
INPUT_EC2-IMAGE-ID=
16-
INPUT_EC2-INSTANCE-TYPE=
15+
INPUT_IMAGE-ID=
16+
INPUT_INSTANCE-TYPE=
1717
INPUT_SUBNET-ID=
1818
INPUT_SECURITY-GROUP-ID=
1919
INPUT_LABELS=
20-
INPUT_EC2-INSTANCE-ID=
20+
INPUT_INSTANCE-ID=
2121
INPUT_IAM-ROLE-NAME=
2222
INPUT_SPOT-INSTANCE=
23+
INPUT_ROOT-VOLUME-DEVICE=
24+
INPUT_ROOT-VOLUME-TYPE=
25+
INPUT_ROOT-VOLUME-SIZE=
2326
INPUT_AWS-RESOURCE-TAGS=
2427
INPUT_RUNNER-HOME-DIR=
2528
INPUT_PRE-RUNNER-SCRIPT=

.github/workflows/testing.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ jobs:
3131
mode: start
3232
github-token: ${{ secrets.RUNNER_GITHUB_REPOS_PAT }}
3333
labels: Linux,ARM64,AL2023
34-
ec2-image-id: ${{ vars.RUNNER_ARM64_AMI_ID }}
35-
# runner could lose connection to GitHub Actions
36-
# if using instance type smaller than t4g.xlarge
37-
ec2-instance-type: ${{ vars.RUNNER_ARM64_INSTANCE_TYPE }}
34+
image-id: ${{ vars.RUNNER_ARM64_AMI_ID }}
35+
instance-type: ${{ vars.RUNNER_ARM64_INSTANCE_TYPE }}
3836
spot-instance: 'true'
3937
root-volume-size: '${{ vars.RUNNER_ROOT_VOLUME_SIZE }}'
4038
subnet-id: ${{ vars.RUNNER_SUBNET_ID }}
@@ -60,10 +58,10 @@ jobs:
6058
labels-json=["${csv//,/\",\"}"]
6159
EOF
6260
outputs:
63-
labels-csv: '${{ steps.output.outputs.labels-csv }}'
61+
runner-name: ${{ steps.runner.outputs.runner-name }}
62+
instance-id: ${{ steps.runner.outputs.instance-id }}
6463
labels-json: '${{ steps.output.outputs.labels-json }}'
65-
instance-id: ${{ steps.runner.outputs.ec2-instance-id }}
66-
runner-name: ${{ steps.start-runner.outputs.runner-name }}
64+
labels-csv: '${{ steps.output.outputs.labels-csv }}'
6765

6866
manual-approval:
6967
runs-on: ubuntu-latest
@@ -111,4 +109,4 @@ jobs:
111109
mode: stop
112110
github-token: ${{ secrets.RUNNER_GITHUB_REPOS_PAT }}
113111
labels: ${{ needs.launch-runner.outputs.labels-csv }}
114-
ec2-instance-id: ${{ needs.launch-runner.outputs.instance-id }}
112+
instance-id: ${{ needs.launch-runner.outputs.instance-id }}

README.md

Lines changed: 25 additions & 23 deletions
Large diffs are not rendered by default.

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ inputs:
1616
description: >-
1717
GitHub Personal Access Token with the 'repo' scope assigned.
1818
required: true
19-
ec2-image-id:
19+
image-id:
2020
description: >-
2121
EC2 Image ID (AMI). The new runner will be launched from this image.
2222
This action is compatible with Amazon Linux 2023 images.
2323
This input is required if you use the 'start' mode.
2424
required: false
25-
ec2-instance-type:
25+
instance-type:
2626
description: >-
2727
EC2 Instance Type.
2828
This input is required if you use the 'start' mode.
@@ -46,7 +46,7 @@ inputs:
4646
Use these labels to remove the runner from GitHub when the runner is no longer needed.
4747
This input is required if you use the 'stop' mode.
4848
required: false
49-
ec2-instance-id:
49+
instance-id:
5050
description: >-
5151
EC2 Instance ID of the created runner.
5252
This ID is provided by the output of the action in 'start' mode.
@@ -106,7 +106,7 @@ outputs:
106106
These labels are used in two cases:
107107
- to use as the 'runs-on' property value of subsequent jobs;
108108
- to remove the runner from GitHub when it is no longer needed.
109-
ec2-instance-id:
109+
instance-id:
110110
description: >-
111111
EC2 Instance ID of the created runner.
112112
This ID is used to terminate the EC2 instance when the runner is no longer needed.

dist/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143746,8 +143746,8 @@ async function startEc2Instance(labels, githubRegistrationToken) {
143746143746
const input = {
143747143747
MinCount: 1,
143748143748
MaxCount: 1,
143749-
ImageId: config.input.ec2ImageId,
143750-
InstanceType: config.input.ec2InstanceType,
143749+
ImageId: config.input.imageId,
143750+
InstanceType: config.input.instanceType,
143751143751
InstanceMarketOptions: config.input.spotInstance ? { MarketType: 'spot' } : undefined,
143752143752
EbsOptimized: true,
143753143753
BlockDeviceMappings: [
@@ -143772,48 +143772,48 @@ async function startEc2Instance(labels, githubRegistrationToken) {
143772143772
try {
143773143773
const command = new RunInstancesCommand(input);
143774143774
const response = await client.send(command);
143775-
const ec2InstanceId = response.Instances[0].InstanceId;
143776-
core.info(`AWS EC2 instance ${ec2InstanceId} has started`);
143777-
return ec2InstanceId;
143775+
const instanceId = response.Instances[0].InstanceId;
143776+
core.info(`AWS EC2 instance ${instanceId} has started`);
143777+
return instanceId;
143778143778
} catch (error) {
143779143779
core.error('AWS EC2 instance launch error');
143780143780
throw error;
143781143781
}
143782143782
}
143783143783

143784-
async function waitForInstanceRunning(ec2InstanceId) {
143784+
async function waitForInstanceRunning(instanceId) {
143785143785
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2/Variable/waitUntilInstanceRunning
143786143786
const params = {
143787143787
client: client,
143788143788
maxWaitTime: 60 * 5,
143789143789
};
143790143790
const input = {
143791-
InstanceIds: [ec2InstanceId],
143791+
InstanceIds: [instanceId],
143792143792
};
143793143793

143794143794
try {
143795143795
await waitUntilInstanceRunning(params, input);
143796-
core.info(`AWS EC2 instance ${ec2InstanceId} is up and running`);
143796+
core.info(`AWS EC2 instance ${instanceId} is up and running`);
143797143797
return;
143798143798
} catch (error) {
143799-
core.error(`AWS EC2 instance ${ec2InstanceId} initialization error`);
143799+
core.error(`AWS EC2 instance ${instanceId} initialization error`);
143800143800
throw error;
143801143801
}
143802143802
}
143803143803

143804143804
async function terminateEc2Instance() {
143805143805
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ec2/command/TerminateInstancesCommand
143806143806
const input = {
143807-
InstanceIds: [config.input.ec2InstanceId],
143807+
InstanceIds: [config.input.instanceId],
143808143808
};
143809143809

143810143810
try {
143811143811
const command = new TerminateInstancesCommand(input);
143812143812
await client.send(command);
143813-
core.info(`AWS EC2 instance ${config.input.ec2InstanceId} has terminated`);
143813+
core.info(`AWS EC2 instance ${config.input.instanceId} has terminated`);
143814143814
return;
143815143815
} catch (error) {
143816-
core.error(`AWS EC2 instance ${config.input.ec2InstanceId} termination error`);
143816+
core.error(`AWS EC2 instance ${config.input.instanceId} termination error`);
143817143817
throw error;
143818143818
}
143819143819
}
@@ -143838,12 +143838,12 @@ class Config {
143838143838
this.input = {
143839143839
mode: core.getInput('mode'),
143840143840
githubToken: core.getInput('github-token'),
143841-
ec2ImageId: core.getInput('ec2-image-id'),
143842-
ec2InstanceType: core.getInput('ec2-instance-type'),
143841+
imageId: core.getInput('image-id'),
143842+
instanceType: core.getInput('instance-type'),
143843143843
subnetId: core.getInput('subnet-id'),
143844143844
securityGroupId: core.getInput('security-group-id'),
143845143845
labels: core.getInput('labels'),
143846-
ec2InstanceId: core.getInput('ec2-instance-id'),
143846+
instanceId: core.getInput('instance-id'),
143847143847
iamRoleName: core.getInput('iam-role-name'),
143848143848
spotInstance: core.getBooleanInput('spot-instance'),
143849143849
rootVolumeDevice: core.getInput('root-volume-device'),
@@ -143886,11 +143886,11 @@ class Config {
143886143886
}
143887143887

143888143888
if (this.input.mode === 'start') {
143889-
if (!this.input.ec2ImageId || !this.input.ec2InstanceType || !this.input.subnetId || !this.input.securityGroupId) {
143889+
if (!this.input.imageId || !this.input.instanceType || !this.input.subnetId || !this.input.securityGroupId) {
143890143890
throw new Error(`Not all the required inputs are provided for the 'start' mode`);
143891143891
}
143892143892
} else if (this.input.mode === 'stop') {
143893-
if (!this.input.labels || !this.input.ec2InstanceId) {
143893+
if (!this.input.labels || !this.input.instanceId) {
143894143894
throw new Error(`Not all the required inputs are provided for the 'stop' mode`);
143895143895
}
143896143896
} else {
@@ -145979,7 +145979,7 @@ const gh = __nccwpck_require__(6989);
145979145979

145980145980
function setOutput(labels, instanceId, runnerName) {
145981145981
core.setOutput('labels', labels);
145982-
core.setOutput('ec2-instance-id', instanceId);
145982+
core.setOutput('instance-id', instanceId);
145983145983
core.setOutput('runner-name', runnerName);
145984145984
}
145985145985

src/aws.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ async function startEc2Instance(labels, githubRegistrationToken) {
5151
const input = {
5252
MinCount: 1,
5353
MaxCount: 1,
54-
ImageId: config.input.ec2ImageId,
55-
InstanceType: config.input.ec2InstanceType,
54+
ImageId: config.input.imageId,
55+
InstanceType: config.input.instanceType,
5656
InstanceMarketOptions: config.input.spotInstance ? { MarketType: 'spot' } : undefined,
5757
EbsOptimized: true,
5858
BlockDeviceMappings: [
@@ -77,48 +77,48 @@ async function startEc2Instance(labels, githubRegistrationToken) {
7777
try {
7878
const command = new RunInstancesCommand(input);
7979
const response = await client.send(command);
80-
const ec2InstanceId = response.Instances[0].InstanceId;
81-
core.info(`AWS EC2 instance ${ec2InstanceId} has started`);
82-
return ec2InstanceId;
80+
const instanceId = response.Instances[0].InstanceId;
81+
core.info(`AWS EC2 instance ${instanceId} has started`);
82+
return instanceId;
8383
} catch (error) {
8484
core.error('AWS EC2 instance launch error');
8585
throw error;
8686
}
8787
}
8888

89-
async function waitForInstanceRunning(ec2InstanceId) {
89+
async function waitForInstanceRunning(instanceId) {
9090
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ec2/Variable/waitUntilInstanceRunning
9191
const params = {
9292
client: client,
9393
maxWaitTime: 60 * 5,
9494
};
9595
const input = {
96-
InstanceIds: [ec2InstanceId],
96+
InstanceIds: [instanceId],
9797
};
9898

9999
try {
100100
await waitUntilInstanceRunning(params, input);
101-
core.info(`AWS EC2 instance ${ec2InstanceId} is up and running`);
101+
core.info(`AWS EC2 instance ${instanceId} is up and running`);
102102
return;
103103
} catch (error) {
104-
core.error(`AWS EC2 instance ${ec2InstanceId} initialization error`);
104+
core.error(`AWS EC2 instance ${instanceId} initialization error`);
105105
throw error;
106106
}
107107
}
108108

109109
async function terminateEc2Instance() {
110110
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ec2/command/TerminateInstancesCommand
111111
const input = {
112-
InstanceIds: [config.input.ec2InstanceId],
112+
InstanceIds: [config.input.instanceId],
113113
};
114114

115115
try {
116116
const command = new TerminateInstancesCommand(input);
117117
await client.send(command);
118-
core.info(`AWS EC2 instance ${config.input.ec2InstanceId} has terminated`);
118+
core.info(`AWS EC2 instance ${config.input.instanceId} has terminated`);
119119
return;
120120
} catch (error) {
121-
core.error(`AWS EC2 instance ${config.input.ec2InstanceId} termination error`);
121+
core.error(`AWS EC2 instance ${config.input.instanceId} termination error`);
122122
throw error;
123123
}
124124
}

src/config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class Config {
66
this.input = {
77
mode: core.getInput('mode'),
88
githubToken: core.getInput('github-token'),
9-
ec2ImageId: core.getInput('ec2-image-id'),
10-
ec2InstanceType: core.getInput('ec2-instance-type'),
9+
imageId: core.getInput('image-id'),
10+
instanceType: core.getInput('instance-type'),
1111
subnetId: core.getInput('subnet-id'),
1212
securityGroupId: core.getInput('security-group-id'),
1313
labels: core.getInput('labels'),
14-
ec2InstanceId: core.getInput('ec2-instance-id'),
14+
instanceId: core.getInput('instance-id'),
1515
iamRoleName: core.getInput('iam-role-name'),
1616
spotInstance: core.getBooleanInput('spot-instance'),
1717
rootVolumeDevice: core.getInput('root-volume-device'),
@@ -54,11 +54,11 @@ class Config {
5454
}
5555

5656
if (this.input.mode === 'start') {
57-
if (!this.input.ec2ImageId || !this.input.ec2InstanceType || !this.input.subnetId || !this.input.securityGroupId) {
57+
if (!this.input.imageId || !this.input.instanceType || !this.input.subnetId || !this.input.securityGroupId) {
5858
throw new Error(`Not all the required inputs are provided for the 'start' mode`);
5959
}
6060
} else if (this.input.mode === 'stop') {
61-
if (!this.input.labels || !this.input.ec2InstanceId) {
61+
if (!this.input.labels || !this.input.instanceId) {
6262
throw new Error(`Not all the required inputs are provided for the 'stop' mode`);
6363
}
6464
} else {

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const gh = require('./gh');
55

66
function setOutput(labels, instanceId, runnerName) {
77
core.setOutput('labels', labels);
8-
core.setOutput('ec2-instance-id', instanceId);
8+
core.setOutput('instance-id', instanceId);
99
core.setOutput('runner-name', runnerName);
1010
}
1111

0 commit comments

Comments
 (0)