Skip to content

Commit 816e24c

Browse files
authored
Fix user data script for EC2 instance (#14)
1 parent 6a59c21 commit 816e24c

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Use the following steps to prepare your workflow for running on your EC2 self-ho
9191

9292
**3. Prepare EC2 image**
9393

94-
1. Create a new EC2 image (AMI) from the Linux distribution you need.
94+
1. Create a new EC2 image (AMI) based on Amazon Linux 2.
9595
You don't need to install anything special beforehand into the AMI.
9696
The action will install all the necessary tools during the EC2 instance creation.
9797

@@ -120,7 +120,7 @@ Now you're ready to go!
120120
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121121
| `mode` | Always required. | Specify here which mode you want to use:<br>- `start` - to start a new runner;<br>- `stop` - to stop the previously created runner. |
122122
| `github-token` | Always required. | GitHub Personal Access Token with the `repo` scope assigned. |
123-
| `ec2-image-id` | Required if you use the `start` mode. | EC2 Image Id (AMI). <br><br> The new runner will be launched from this image. The action is compatible only with Linux images. |
123+
| `ec2-image-id` | Required if you use the `start` mode. | EC2 Image Id (AMI). <br><br> The new runner will be launched from this image. The action is compatible with Amazon Linux 2 images. |
124124
| `ec2-instance-type` | Required if you use the `start` mode. | EC2 Instance Type. |
125125
| `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. |
126126
| `security-group-id` | Required if you use the `start` mode. | EC2 Security Group Id. <br><br> The security group should belong to the same VPC as the specified subnet. |

dist/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55088,16 +55088,21 @@ const config = __webpack_require__(34570);
5508855088
async function startEc2Instance(label, githubRegistrationToken) {
5508955089
const ec2 = new AWS.EC2();
5509055090

55091+
// user data scripts are run as the root user
55092+
// Docker is required for running Docker container actions
5509155093
const userData = [
5509255094
'#!/bin/bash',
5509355095
'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1',
55094-
'mkdir /actions-runner && cd /actions-runner',
55096+
'yum update -y',
55097+
'yum install docker -y',
55098+
'yum install git -y',
55099+
'service docker start',
55100+
'mkdir actions-runner && cd actions-runner',
5509555101
'curl -O -L https://github.com/actions/runner/releases/download/v2.274.2/actions-runner-linux-x64-2.274.2.tar.gz',
5509655102
'tar xzf ./actions-runner-linux-x64-2.274.2.tar.gz',
55097-
'useradd github',
55098-
'chown -R github:github /actions-runner',
55099-
`su github -c "./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}"`,
55100-
'su github -c "./run.sh"',
55103+
'export RUNNER_ALLOW_RUNASROOT=1',
55104+
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
55105+
'./run.sh',
5510155106
];
5510255107

5510355108
const params = {

src/aws.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ const config = require('./config');
55
async function startEc2Instance(label, githubRegistrationToken) {
66
const ec2 = new AWS.EC2();
77

8+
// user data scripts are run as the root user
9+
// Docker is required for running Docker container actions
810
const userData = [
911
'#!/bin/bash',
1012
'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1',
11-
'mkdir /actions-runner && cd /actions-runner',
13+
'yum update -y',
14+
'yum install docker -y',
15+
'yum install git -y',
16+
'service docker start',
17+
'mkdir actions-runner && cd actions-runner',
1218
'curl -O -L https://github.com/actions/runner/releases/download/v2.274.2/actions-runner-linux-x64-2.274.2.tar.gz',
1319
'tar xzf ./actions-runner-linux-x64-2.274.2.tar.gz',
14-
'useradd github',
15-
'chown -R github:github /actions-runner',
16-
`su github -c "./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}"`,
17-
'su github -c "./run.sh"',
20+
'export RUNNER_ALLOW_RUNASROOT=1',
21+
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
22+
'./run.sh',
1823
];
1924

2025
const params = {

0 commit comments

Comments
 (0)