🖥️ EC2 GHA Runner: Start Stop - dvsa/des-workflow-actions GitHub Wiki
Description
This reusable workflow is called from multiple caller workflows to set up an EC2 instance as a GitHub Actions runner, minimising the monthly free minutes used for GitHub hosted runners and eliminating the need to manage a dedicated instance in AWS. This workflow was created to eliminate the need to configure AWS credentials in the caller workflow every time we wanted to set up a runner. The workflow utilises this action.
Workflow Triggers
On Workflow Call
This workflow is called from multiple repositories to start and stop a GHA runner.
Environment Variables
Name |
Description |
GHA_RUNNER_EC2_AMI_ID |
The AMI ID to be used. The new runner will be launched from this image. |
GHA_RUNNER_EC2_INSTANCE_TYPE |
The AWS instance type to be used for the runner. |
GHA_RUNNER_SUBNET_ID |
The subnet ID to use within AWS. |
GHA_RUNNER_SG_ID |
The security group ID to be used within AWS. |
GHA_RUNNER_IAM_ROLE_NAME |
IAM role name to attach to the created EC2 runner |
Inputs
Name |
Description |
Options |
action |
The action to take |
start | stop |
pre-runner-script |
Specifies bash commands to run before the runner starts |
N/A |
runner-label |
Name of the unique label assigned to the runner. |
N/A |
ec2-instance-id |
The ID of the created EC2 instance to be stopped |
N/A |
Outputs
Name |
Description |
runner-label |
Name of the unique label assigned to the runner |
ec2-instance-id |
EC2 Instance Id of the created runner |
Notes
- Requires the secrets AWS_ACCOUNT_ID, DVSA_AWS_REGION, & GH_TOKEN to be set up in the caller repository.
- Secrets are explicitly defined so that we can conditionally select the AWS account ID.