diff --git a/.eslintrc.yml b/.eslintrc.yml index f70075bb..195f39ce 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,10 +2,11 @@ env: es6: true node: true jest: true + es2020: true extends: - eslint:recommended parserOptions: - ecmaVersion: 2018 + ecmaVersion: 2020 sourceType: module rules: no-use-before-define: error diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ef4a8daf --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +dist/index.js: $(wildcard src/*.js) + npm run package + +docker-build: + docker run --rm -ti -v "$(PWD):/src" node:16 bash -c "cd src && npm install && make" + +docker-lint: + docker run --rm -ti -v "$(PWD):/src" node:16 bash -c "cd src && npm install && npm run lint" + +.PHONY: docker-build diff --git a/README.md b/README.md index 44adbd71..77560671 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,14 @@ Check the [internal docs](https://docs.shiphero.xyz/ci.html#horizontally-scaled- - [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. - [Support for using spot instances](https://github.com/machulav/ec2-github-runner/pull/171) + +## Build +```sh +make docker-build +``` + +Or using node 16: +```sh +npm install +make +``` diff --git a/dist/index.js b/dist/index.js index d79d45ad..eeea2938 100644 --- a/dist/index.js +++ b/dist/index.js @@ -65286,8 +65286,9 @@ function buildUserDataScript(githubRegistrationToken, label) { `echo "${config.input.preRunnerScript}" > pre-runner-script.sh`, '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', - 'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz', + "VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | grep tag_name | grep -oP '\\d+(\\.\\d+)*')", + 'curl -O -L https://github.com/actions/runner/releases/download/v${VERSION}/actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz', + 'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz', 'export RUNNER_ALLOW_RUNASROOT=1', `./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label} --name $(hostname)-$(uuidgen)`, './run.sh', diff --git a/src/aws.js b/src/aws.js index cfa644c6..f077b191 100644 --- a/src/aws.js +++ b/src/aws.js @@ -23,8 +23,9 @@ function buildUserDataScript(githubRegistrationToken, label) { `echo "${config.input.preRunnerScript}" > pre-runner-script.sh`, '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', - 'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz', + "VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | grep tag_name | grep -oP '\\d+(\\.\\d+)*')", + 'curl -O -L https://github.com/actions/runner/releases/download/v${VERSION}/actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz', + 'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-${VERSION}.tar.gz', 'export RUNNER_ALLOW_RUNASROOT=1', `./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label} --name $(hostname)-$(uuidgen)`, './run.sh',