Commit Graph
83 Commits
Author SHA1 Message Date
Mark Young d21b822a8a Refresh app tokens before deregistration 2025-11-19 09:00:18 -06:00
chorbea 9a11c2c002 Defaulted RUNNER_NAME_PREFIX 2025-07-14 09:23:52 +01:00
chorbea e6a5d8eb29 allow hostname without github-runner prefix to avoid 64-char limit 2025-07-04 10:11:55 +01:00
Sascha HenningandGitHub 4ddfd14a3c fix RUNNER_WORKDIR not created if parent folder does not exist 2025-05-20 15:01:32 +02:00
Mark Young b832d927ad Force DISABLE_AUTOMATIC_DEREGISTRATION to be true on reusable runners, add tests 2025-02-24 11:19:25 -06:00
Bodo Graumann cd473a430b Apply suggestions from PR 2024-10-05 20:08:27 +02:00
Bodo GraumannandGitHub 30c82803ce Make sure there is no remnant runner config before configuring
Closes #402
2024-10-05 09:25:14 +02:00
tomoya-kawaguchi d70e859f71 chore: use local var 2024-09-06 16:56:27 +09:00
tomoya-kawaguchi e8a305ae15 chore: unset configuration environment variables if flag is set 2024-09-06 16:54:52 +09:00
Marcus Young 76383dae6c Add goss tests 2024-09-05 10:01:22 -05:00
Marcus Young 15035d1ad3 Add better signal trap for debugging 2024-04-25 11:02:50 -05:00
Daniel Bloom db83ada502 whitespace 2023-11-20 12:21:45 -08:00
Jason CubicandGitHub 6c002dcf62 Update entrypoint.sh
added truth check to disable adding default labels
2023-10-26 16:48:10 -07:00
myoung34andGitHub 54dad9f3d0 Update entrypoint.sh 2023-09-02 10:11:54 -05:00
kmkacpermajor bac9d7cfb1 fix 2023-08-25 19:12:33 +02:00
Marcus Young 26e256d5d7 Fix path to chown for debian and ubuntu delta 2023-06-16 07:51:55 -05:00
Job bbd2bb803c Moved Docker start command before runner start 2023-05-15 21:14:08 +00:00
Job 894801ed03 Added ability to start docker service on startup 2023-05-15 19:59:54 +00:00
Fabian Fuelling 4fb0cb7f90 Make default workdir a subfolder under /_work 2023-02-07 16:00:54 +01:00
Marcus Young e9a5ccae9e Add new boolean for randomized suffix 2023-01-31 08:36:49 -06:00
Marcus Young 006c50f8c7 Add empty check for /etc/hostname 2023-01-31 08:12:09 -06:00
Marcus Young 5d5d7382ad Bugfix: /etc/hostname is not guaranteed, sane default to random string 2023-01-30 11:11:21 -06:00
Aleksandr Efremenkov 8ae5f97150 added using docker hostname instead manual generated random, updated README 2023-01-16 16:10:48 +02:00
myoung34andGitHub 759fd9b51d Merge pull request #264 from Abramo-Bagnara/master
Allow to put APP_PRIVATE_KEY in Docker env file. Introduced APP_LOGIN…
2022-12-12 14:56:59 -06:00
Lukas Magel 21dd8bec01 Change recursive chown to flat chown for tools directory
If the tools cache is already populated with tooling in a derived docker
image, performing a recursive chown significantly slows down ephemeral
runner startup.
2022-12-12 20:52:43 +01:00
Abramo Bagnara 76e955de4e Improved backward compatibility with sane defaults for APP_LOGIN. 2022-12-09 08:08:27 +01:00
Abramo Bagnara 0d5e2807ea Allow to put APP_PRIVATE_KEY in Docker env file. Introduced APP_LOGIN to fix access token retrieval in case of multiple GitHub's App subscriber. 2022-12-06 08:50:29 +01:00
Manu Bretelle 5dd79b7933 entrypoint: make APP_ID/APP_PRIVATE_KEY mutually exclusive with
{ACCESS,RUNNER}_TOKEN.

```
$ docker run --env RUNNER_TOKEN=foo --env APP_ID=1234 --env APP_PRIVATE_KEY="$(<~/Downloads/cert.pem)" runner_app
REPO_URL required for repo runners
Runner reusage is disabled
ERROR: ACCESS_TOKEN or RUNNER_TOKEN provided but are mutually exclusive with APP_ID and APP_PRIVATE_KEY.
$ docker run --env ACCESS_TOKEN=foo --env APP_ID=1234 --env APP_PRIVATE_KEY="$(<~/Downloads/cert.pem)" runner_app
REPO_URL required for repo runners
Runner reusage is disabled
ERROR: ACCESS_TOKEN or RUNNER_TOKEN provided but are mutually exclusive with APP_ID and APP_PRIVATE_KEY.
$ docker run --env ACCESS_TOKEN=foo --env APP_ID=1234 --env APP_PRIVATE_KEY="$(<~/Downloads/cert.pem)" runner_app
$ docker run --env APP_ID=250536  runner_app
REPO_URL required for repo runners
Runner reusage is disabled
ERROR: Both APP_ID and APP_PRIVATE_KEY must be specified.
$ docker run --env APP_ID=1234 --env APP_PRIVATE_KEY="$(<~/Downloads/cert.pem)" runner_app

REPO_URL required for repo runners
Runner reusage is disabled
Obtaining access token for app_id 1234
Obtaining the token of the runner
curl: (22) The requested URL returned error: 404
Configuring

--------------------------------------------------------------------------------
|        ____ _ _   _   _       _          _        _   _                      |
|       / ___(_) |_| | | |_   _| |__      / \   ___| |_(_) ___  _ __  ___      |
|      | |  _| | __| |_| | | | | '_ \    / _ \ / __| __| |/ _ \| '_ \/ __|     |
|      | |_| | | |_|  _  | |_| | |_) |  / ___ \ (__| |_| | (_) | | | \__ \     |
|       \____|_|\__|_| |_|\__,_|_.__/  /_/   \_\___|\__|_|\___/|_| |_|___/     |
|                                                                              |
|                       Self-hosted runner registration                        |
|                                                                              |
--------------------------------------------------------------------------------

Invalid configuration provided for url. Terminating unattended configuration.
An error occurred: Not configured. Run config.(sh/cmd) to configure the runner.
```
2022-11-10 13:31:22 -08:00
Manu Bretelle b2d820fa70 Add suport for using a GitHub app to run the runner.
If both `APP_ID` and `APP_PRIVATE_KEY` are set, `entrypoint.sh` will
fetch an `ACCESS_TOKEN` for the GitHub app using `app_token.sh` script.

`ACCESS_TOKEN` will get set, and `entrypoint.sh` will carry on as it
used to had `ACCESS_TOKEN` been set from the environment variable.
2022-11-10 13:31:22 -08:00
chantra d36049625a Fix ephemeral support
The quotes added in d6e229ec5d cause
`ephemeral` to evaluate as false when `DISABLE_AUTO_UPDATE` was not set.

This is explained in details in #249. This diff changes the logic to use
an array where extra parameters are being added.
When calling config.sh, the array is expanded.

Testing:
../self_hosted_runner.env contains
```
EPHEMERAL=true
```

Before: https://gist.github.com/chantra/443dfaa60d964d938bcb1c020781ca00
we can see multiple jobs got scheduled on the runner

After: https://gist.github.com/chantra/061dc471c63964c01a2e3733a53bd3ec
we can see that when the job finished, the container shutdown.

After with DISABLE_AUTO_UPDATE set: https://gist.github.com/chantra/df0102c7340b8f6bfd458ec56d9fa29c

Also adding `set -x` before the call to `config.sh` revealed the
arguments were correctly added.

Fixes #249
2022-09-30 14:49:04 -07:00
Marcus Young d6e229ec5d shellcheck entrypoint.sh 2022-09-10 19:23:25 -05:00
Marcus Young be89b0b426 Add chown optimization, set up shellcheck 2022-09-10 19:08:40 -05:00
James Stocker 66be83e2d0 Update logic at the end as requested 2022-09-02 12:26:29 +02:00
41e804d8f3 Update entrypoint.sh
Co-authored-by: myoung34 <[email protected]>
2022-09-02 12:23:31 +02:00
845c8560f2 Update entrypoint.sh
Co-authored-by: myoung34 <[email protected]>
2022-09-02 12:23:22 +02:00
dbfb56f306 Update entrypoint.sh
Co-authored-by: myoung34 <[email protected]>
2022-09-02 12:23:16 +02:00
12193fe94a Update entrypoint.sh
Co-authored-by: myoung34 <[email protected]>
2022-09-02 12:22:36 +02:00
James Stocker 5efaecb8fb Check to see if not running as root
Change logic slightly avoid edge case
2022-08-30 10:22:25 +02:00
Marcus Young 2560bbb789 Dont run as non-root by default 2022-08-01 16:52:32 -05:00
Marcus Young c6fcbc55fd Last changes for run-as runner user 2022-07-26 12:07:03 -05:00
Marcus Young 656280cd9e Swap USER directive for gosu for runtime permissions 2022-07-26 09:44:02 -05:00
Marcus Young a21f89e912 Fix de-registration 2022-04-18 09:49:38 -05:00
Marcus Young 9130b86b39 Fix disable auto update 2022-04-01 21:54:08 -05:00
Marcus Young b379dd3f69 Add DISABLE_AUTO_UPDATE flag to disable automatic updates 2022-02-03 09:30:51 -06:00
Kenta KaseandGitHub c6a72fbc37 Fix configure command when EPHEMERAL is disabled 2021-11-27 18:09:11 +09:00
Kenta KaseandGitHub a70242726e Support --ephemeral runner option 2021-11-24 09:18:49 +09:00
Gustav TonérandGitHub bd0658f528 Fix typo in entrypoint.sh log output 2021-09-22 13:24:20 +02:00
Marcus Young 282be6864b Fix deregistration hijacking 2021-09-15 10:23:46 -05:00
Joey Parrish 527cf6352b Fix runner deregistration with ACCESS_TOKEN
This fixes runner deregistration, which needs to have ACCESS_TOKEN still
defined to fetch a fresh RUNNER_TOKEN for deregistration.

The original purpose of unsetting the variables would seem to be for
security, to make sure they unavailable to the jobs running in the
container. Unexporting the variables achieves the same goal, but leaves
them available to the entrypoint later when it runs the deregistration
process.
2021-09-10 08:56:00 -07:00
Marcus Young 18f1c7deb6 Simplify runner reusage, add some output to show logic. Fix readme 2021-07-22 21:15:31 -05:00