mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-30 19:22:09 +00:00
This PR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [forgejo/runner](https://code.forgejo.org/forgejo/runner) | major | `9.1.1` -> `10.0.1` |
---
### Release Notes
<details>
<summary>forgejo/runner (forgejo/runner)</summary>
### [`v10.0.1`](https://code.forgejo.org/forgejo/runner/releases/tag/v10.0.1)
[Compare Source](https://code.forgejo.org/forgejo/runner/compare/v10.0.0...v10.0.1)
- [User guide](https://forgejo.org/docs/next/user/actions/overview/)
- [Administrator guide](https://forgejo.org/docs/next/admin/actions/)
- [Container images](https://code.forgejo.org/forgejo/-/packages/container/runner/versions)
Release Notes
***
### [`v10.0.0`](https://code.forgejo.org/forgejo/runner/releases/tag/v10.0.0)
[Compare Source](https://code.forgejo.org/forgejo/runner/compare/v9.1.1...v10.0.0)
> **Warning** Upgrade to v10.0.1 instead. A regression was found on `pull_request_target` events and is fixed in the [v10.0.1 release](https://code.forgejo.org/forgejo/runner/releases/tag/v10.0.1).
- [User guide](https://forgejo.org/docs/next/user/actions/overview/)
- [Administrator guide](https://forgejo.org/docs/next/admin/actions/)
- [Container images](https://code.forgejo.org/forgejo/-/packages/container/runner/versions)
Release Notes
- [PR](https://code.forgejo.org/forgejo/runner/pulls/925): <!--number 925 --><!--line 0 --><!--description Zml4KHNlY3VyaXR5KTogcHJldmVudCBvbjogcHVsbF9yZXF1ZXN0IGFjdGlvbnMgZnJvbSBtdXRhdGluZyBjYWNoZXMgb2Ygb3RoZXIgd29ya2Zsb3cgZXZlbnRz-->fix(security): prevent on: pull\_request actions from mutating caches of other workflow events<!--description-->
forgej-runner currently creates a safer execution environment for workflows triggered by pull requests by denying those workflows access to the repository's secrets, preventing pull requests from compromising the confidentiality of the secrets.
Workflows do have access to write to the action cache, which is shared with future workflow executions, including executions that may have access to repository secrets. This was assumed safe as the cache is a "write-once" operation based upon the cache key; if an execution writes to that cache, it will be read by other workflows only if a matching key parameter is provided, and it can not be modified again. These assumptions were identified as weak security practices with known workarounds.
It is possible for a malicious pull request to mutate the shared cache and embed untrusted artifacts, which may later be executed in workflow executions with access to secrets, risking the confidentiality of those secrets.
In order to eliminate this risk, workflows executing with the `pull_request` and `pull_request_target` events have their write operations to the cache isolated to future workflow executions from the same pull request. They can continue to read from the shared cache if applicable.
If using an external cache server configuration, both the cache server and other instances of the runner must be running the same software version. The recommended upgrade procedure in this configuration is to bring all runners offline, upgrade the cache server to the latest release and bring it online, and then bring all other runners online.
- [PR](https://code.forgejo.org/forgejo/runner/pulls/924): <!--number 924 --><!--line 0 --><!--description Zml4KHNlY3VyaXR5KTogZW5zdXJlIHVuaXF1ZSBuYW1lcyBmb3IgY29udGFpbmVyIGltYWdlcyBjcmVhdGVkIGJ5IGFjdGlvbnM=-->fix(security): ensure unique names for container images created by actions<!--description-->
Without this fix, when a workflow ran a local [docker action](https://forgejo.org/docs/next/user/actions/actions/#docker-actions) (e.g. the [example in the end-to-end tests](
|
||
---|---|---|
.. | ||
forgejo-runner-service.sh | ||
README.md |
forgejo-runner-service.sh installs a Forgejo runner within an LXC container and runs it from a systemd service.
Quickstart
- Install:
sudo wget -O /usr/local/bin/forgejo-runner-service.sh https://code.forgejo.org/forgejo/runner/raw/branch/main/examples/lxc-systemd/forgejo-runner-service.sh && sudo chmod +x /usr/local/bin/forgejo-runner-service.sh
- Obtain a runner registration token ($TOKEN)
- Choose a serial number that is not already in use in
/etc/forgejo-runner
- Create a runner
INPUTS_SERIAL=30 INPUTS_TOKEN=$TOKEN INPUTS_FORGEJO=https://code.forgejo.org forgejo-runner-service.sh
- Start
systemctl enable --now forgejo-runner@$INPUTS_SERIAL
- Monitor with:
systemctl status forgejo-runner@$INPUTS_SERIAL
tail --follow=name /var/log/forgejo-runner/$INPUTS_SERIAL.log
Installation or upgrade
Installation
sudo wget -O /usr/local/bin/forgejo-runner-service.sh https://code.forgejo.org/forgejo/runner/raw/branch/main/examples/lxc-systemd/forgejo-runner-service.sh && sudo chmod +x /usr/local/bin/forgejo-runner-service.sh
Upgrade
Warning
runners will not be upgraded immediately, the upgrade will happen when they restart (at
$INPUTS_LIFETIME
intervals).
The following will be upgraded:
forgejo-runner-service.sh
will replace itself with the script found at the provided URL (e.g.https://code.forgejo.org/forgejo/runner/src/tag/v6.3.1/examples/lxc-systemd/forgejo-runner-service.sh
)lxc-helpers*.sh
will be replaced with the version pinned inforgejo-runner-service.sh
forgejo-runner-X.Y.Z
will default to the version hardcoded inforgejo-runner-service.sh
Example:
forgejo-runner-service.sh upgrade https://code.forgejo.org/forgejo/runner/src/tag/v6.3.1/examples/lxc-systemd/forgejo-runner-service.sh
Description
- Each runner is assigned a unique serial number (
$INPUTS_SERIAL
) - The configuration is in
/etc/forgejo-runner/$INPUTS_SERIAL
- The environment variables are in
/etc/forgejo-runner/$INPUTS_SERIAL/env
- The cache is in
/var/lib/forgejo-runner/runner-$INPUTS_SERIAL
- The systemd service unit is
forgejo-runner@$INPUTS_SERIAL
- The logs of the runner daemon are in
/var/log/forgejo-runner/$INPUTS_SERIAL.log
How it works
- Creating a runner (for instance with
INPUTS_SERIAL=30 INPUTS_TOKEN=$TOKEN INPUTS_FORGEJO=https://code.forgejo.org forgejo-runner-service.sh
) will:- use
$INPUTS_TOKEN
to register on$INPUTS_FORGEJO
and save the result in the/etc/forgejo-runner/$INPUTS_SERIAL/.runner
file - generate a default configuration file in the
/etc/forgejo-runner/$INPUTS_SERIAL/config.yml
file which can then be manually edited
- use
- Each runner is launched in a dedicated LXC container named
runner-$INPUTS_SERIAL-lxc
with the following bind mounts:/etc/forgejo-runner/$INPUTS_SERIAL
/var/lib/forgejo-runner/runner-$INPUTS_SERIAL/.cache/actcache
systemctl start forgejo-runner@$INPUTS_SERIAL
will do the following when it starts and every$INPUTS_LIFETIME
interval after that:- attempt to gracefully stop (SIGTERM) the runner, waiting for all jobs to complete
- forcibly kill the runner if it does not stop within 6h
- shutdown the LXC container and delete it (the volumes bind mounted are preserved)
- create a brand new LXC container (with the specified
$INPUTS_LXC_CONFIG
) - install and run a Forgejo runner daemon in the LXC container using
/etc/forgejo-runner/$INPUTS_SERIAL/config.yml
- redirect the output of the runner to
/var/log/forgejo-runner/$INPUTS_SERIAL.log
systemctl stop forgejo-runner@$INPUTS_SERIAL
will stop the runner but keep the LXC container running
Creation
The creation of a new runner is driven by the following environment variables:
INPUTS_SERIAL
: unique number in the range[10-100]
(check/etc/forgejo-runner
)INPUTS_TOKEN
: a runner registration token obtained from the web UIINPUTS_FORGEJO
: the Forgejo instance from whichINPUTS_TOKEN
was obtained (e.g. https://code.forgejo.org)INPUTS_RUNNER_VERSION
: the version of the Forgejo runner as found in https://code.forgejo.org/forgejo/runner/releases (e.g. 9.0.2)INPUTS_LXC_CONFIG
: the value of the--config
argument of lxc-helpers used when creating the LXC container for the runner (e.g.docker
)INPUTS_LIFETIME
: the LXC container is re-created when its lifetime expires (e.g. 7d)
Hacking
- An existing LXC configuration will not be modified. If
lxc-ls
exists, it is assumed that LXC is configured and ready to be used. - Migrating an existing runner:
serial=10 mkdir /etc/forgejo-runner/$serial cp .runner config.yml /etc/forgejo-runner/$serial INPUTS_SERIAL=$serial INPUTS_FORGEJO=https://code.forgejo.org forgejo-runner-service.sh systemctl status forgejo-runner@$serial
- Set debug by adding
VERBOSE=true
in/etc/forgejo-runner/$INPUTS_SERIAL/env
Use a specific version of the Forgejo runner
The goal is that a LXC container uses a version of the Forgejo runner that is different from the default. It needs to be installed and pinned.
- Install:
INPUTS_RUNNER_VERSION=9.0.2 forgejo-runner-service.sh install_runner
- Pin the version in
/etc/forgejo-runner/N/env
(e.g.INPUTS_RUNNER_VERSION=9.0.2
)