diff --git a/.github/runner/Dockerfile b/.github/runner/Dockerfile index fecddb5..efcba95 100644 --- a/.github/runner/Dockerfile +++ b/.github/runner/Dockerfile @@ -18,13 +18,13 @@ RUN cd /home/docker && mkdir actions-runner && cd actions-runner \ RUN chown -R docker ~docker && /home/docker/actions-runner/bin/installdependencies.sh -COPY start.sh start.sh +COPY entrypoint.sh entrypoint.sh # make the script executable -RUN chmod +x start.sh +RUN chmod +x entrypoint.sh # since the config and run script for actions are not allowed to be run by root, # set the user to "docker" so all subsequent commands are run as the docker user USER docker -ENTRYPOINT ["./start.sh"] \ No newline at end of file +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/.github/runner/docker-compose.yml b/.github/runner/docker-compose.yml index b533bfa..3ecee8e 100644 --- a/.github/runner/docker-compose.yml +++ b/.github/runner/docker-compose.yml @@ -6,7 +6,8 @@ services: context: . args: RUNNER_VERSION: 2.323.0 - container_name: github-runner + # container_name commented to allow for multiple runners + # container_name: github-runner env_file: - .env volumes: diff --git a/.github/runner/entrypoint.sh b/.github/runner/entrypoint.sh new file mode 100644 index 0000000..97e8609 --- /dev/null +++ b/.github/runner/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +REPOSITORY=$REPO +ACCESS_TOKEN=$GH_TOKEN +LABELS=$RUNNER_LABELS + +# echo "REPO ${REPOSITORY}" +# echo "ACCESS_TOKEN ${ACCESS_TOKEN}" + +REG_TOKEN=$(curl -X POST -H "Authorization: token ${ACCESS_TOKEN}" -H "Accept: application/vnd.github+json" https://api.github.com/repos/${REPOSITORY}/actions/runners/registration-token | jq .token --raw-output) + +cd /home/docker/actions-runner + +./config.sh --url https://github.com/${REPOSITORY} --token ${REG_TOKEN} --labels ${LABELS} + +cleanup() { + echo "Removing runner..." + ./config.sh remove --unattended --token ${REG_TOKEN} +} + +trap 'cleanup; exit 130' INT +trap 'cleanup; exit 143' TERM + +./run.sh & wait $! \ No newline at end of file diff --git a/.github/runner/start.sh b/.github/runner/start.sh index 97e8609..891f4d4 100644 --- a/.github/runner/start.sh +++ b/.github/runner/start.sh @@ -1,24 +1,4 @@ -#!/bin/bash -REPOSITORY=$REPO -ACCESS_TOKEN=$GH_TOKEN -LABELS=$RUNNER_LABELS -# echo "REPO ${REPOSITORY}" -# echo "ACCESS_TOKEN ${ACCESS_TOKEN}" - -REG_TOKEN=$(curl -X POST -H "Authorization: token ${ACCESS_TOKEN}" -H "Accept: application/vnd.github+json" https://api.github.com/repos/${REPOSITORY}/actions/runners/registration-token | jq .token --raw-output) - -cd /home/docker/actions-runner - -./config.sh --url https://github.com/${REPOSITORY} --token ${REG_TOKEN} --labels ${LABELS} - -cleanup() { - echo "Removing runner..." - ./config.sh remove --unattended --token ${REG_TOKEN} -} - -trap 'cleanup; exit 130' INT -trap 'cleanup; exit 143' TERM - -./run.sh & wait $! \ No newline at end of file +docker compose up -d --build +# docker compose up -d --build --scale github-runner=2