Skip to content

Commit a3a3676

Browse files
committed
feat(aws): Always download the latest release
Issue We are downloading the runner twice: the old v2.313.0 and the latest (because of the auto-update) Solution - Use the API to get the latest version and just download it - Fix linter - Add makefile and instructions to build the action
1 parent 6b72107 commit a3a3676

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

.eslintrc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ env:
22
es6: true
33
node: true
44
jest: true
5+
es2020: true
56
extends:
67
- eslint:recommended
78
parserOptions:
8-
ecmaVersion: 2018
9+
ecmaVersion: 2020
910
sourceType: module
1011
rules:
1112
no-use-before-define: error

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist/index.js: $(wildcard src/*.js)
2+
npm run package
3+
4+
docker-build:
5+
docker run --rm -ti -v "$(PWD):/src" node:16 bash -c "cd src && npm install && make"
6+
7+
.PHONY: docker-build

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,14 @@ Check the [internal docs](https://docs.shiphero.xyz/ci.html#horizontally-scaled-
2828
- [Avoid failures when other runners are already registered with same name](https://github.com/Shiphero/ec2-github-runner/pull/4) by assigning a random name to the instances.
2929

3030
- [Support for using spot instances](https://github.com/machulav/ec2-github-runner/pull/171)
31+
32+
## Build
33+
```sh
34+
make docker-build
35+
```
36+
37+
Or using node 16:
38+
```sh
39+
npm install
40+
make
41+
```

dist/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65286,8 +65286,9 @@ function buildUserDataScript(githubRegistrationToken, label) {
6528665286
`echo "${config.input.preRunnerScript}" > pre-runner-script.sh`,
6528765287
'source pre-runner-script.sh',
6528865288
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
65289-
'curl -O -L https://github.com/actions/runner/releases/download/v2.313.0/actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz',
65290-
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz',
65289+
"VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | grep tag_name | grep -oP '\d+(\.\d+)*')",
65290+
'curl -O -L https://github.com/actions/runner/releases/download/v${VERSION}/actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz',
65291+
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz',
6529165292
'export RUNNER_ALLOW_RUNASROOT=1',
6529265293
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label} --name $(hostname)-$(uuidgen)`,
6529365294
'./run.sh',

src/aws.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ function buildUserDataScript(githubRegistrationToken, label) {
2323
`echo "${config.input.preRunnerScript}" > pre-runner-script.sh`,
2424
'source pre-runner-script.sh',
2525
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
26-
'curl -O -L https://github.com/actions/runner/releases/download/v2.313.0/actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz',
27-
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz',
26+
"VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | grep tag_name | grep -oP '\d+(\.\d+)*')",
27+
'curl -O -L https://github.com/actions/runner/releases/download/v${VERSION}/actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz',
28+
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz',
2829
'export RUNNER_ALLOW_RUNASROOT=1',
2930
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label} --name $(hostname)-$(uuidgen)`,
3031
'./run.sh',

0 commit comments

Comments
 (0)