Connect GitHub Actions runners
Join a GitHub Actions runner to your network for one job, reach private devices from CI, and remove the runner when the job ends.
Updated · ·By Ivan Vyshniak
Nothing on this page changes with your selection.
The peerlify/github-action action installs the client on a GitHub Actions runner, signs it in to your network, and removes it from the network when the job ends. The steps after it reach your devices like any other device in the network, for example to deploy to a server that has no public address.
Before you start
- Runner. Linux or Windows, GitHub-hosted or self-hosted. macOS runners aren't supported, because the Mac client's background service has to be approved by someone at the Mac. The runner account must be able to install software: passwordless
sudoand systemd on Linux, administrator rights on Windows. GitHub-hosted runners have both. - A tag for CI (recommended). Create a tag such as
ciunder Access → Tags, and write rules for whattag:cimay reach. A device that joins with a tagged key belongs to the tag, not to a person, so person-based rules don't match it. See Tags and groups.
You can give the action an auth key or an API token.
Option 1: an auth key
- In the console, open Settings → Keys and, in Auth keys, click Create key.
- Turn on Ephemeral, so that runners are removed from the network after each job, and Reusable, so that every job can use the key.
- Under Auto-assign tags, choose your CI tag. Set an Expiry and click Generate key.
- In GitHub, save the key as a repository or organization secret named
PEERLIFY_AUTHKEY. - Add the action before the steps that need the network:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Connect to Peerlify
uses: peerlify/github-action@v1
with:
authkey: ${{ secrets.PEERLIFY_AUTHKEY }}
ping: 100.100.0.12 # optional: wait until this device answers
- name: Deploy
run: ssh deploy@100.100.0.12 ./release.shThe key stops working if the person who created it leaves the network. See How keys behave.
If the network has Manual device approval on, a runner that joins with an auth key waits for approval, and the step fails when timeout passes. Approve it on the Devices page, or use an API token instead.
Option 2: an API token
With an API token, the action creates a new single-use, ephemeral auth key for each run, valid for one day, and revokes it when the job ends.
The token's creator needs the Owner or Admin role: creating API tokens requires Owner, Admin or Network admin, and creating auth keys through a token requires the creator to hold Owner, Admin or IT admin at the time of each run. If the action passes tags, the creator must manage them.
- In the console, open Settings → Keys and, under API access tokens, click New token.
- Under Scope, turn off Full access and choose Write for Keys. Also choose Write for Devices, so that the action can approve the runner when the network has Manual device approval on, and remove the runner if it couldn't log out.
- Click Generate token and save the token in GitHub as a secret named
PEERLIFY_API_TOKEN. - Add the action:
- name: Connect to Peerlify
uses: peerlify/github-action@v1
with:
api-token: ${{ secrets.PEERLIFY_API_TOKEN }}
tags: ci
hostname: ci-${{ github.run_id }}The tags must already exist in the network, and the token's creator must manage them; otherwise creating the key fails. See API tokens and the REST API.
Inputs
| Input | Default | Description |
|---|---|---|
authkey | An auth key. Use an ephemeral key. Set authkey or api-token, not both. | |
api-token | An API token with Write for Keys, and preferably for Devices. | |
tags | With api-token only: comma-separated tags for the key the action creates, with or without the tag: prefix. An auth key carries its own tags. | |
hostname | the runner's computer name | The name the runner joins under: 1 to 63 letters, digits and hyphens. If the name is taken, Peerlify adds -1, -2 and so on. |
version | stable | The client version to install: stable, or an exact version to pin. |
ping | Comma-separated device names or addresses that must answer before the step succeeds. | |
timeout | 3m | How long to wait for the runner's address, and for each ping target. |
Outputs
| Output | Description |
|---|---|
ip | The runner's address in the network. |
fqdn | The runner's full name, such as ci-4821.k3x9q2m7pa.peerlify.net. |
client-id | The runner's device ID, as the API takes it. |
network-id | The ID of the network it joined. |
How the runner is removed
When the job ends, whether it passed, failed or was cancelled, the action:
- Runs
peerlify logout. A device that joined with an ephemeral key is removed from the network when it logs out. - With an API token that has Write for Devices, also removes the runner through the API, in case the logout couldn't reach Peerlify.
- With an API token, revokes the key it created for the run.
If the runner disappears before that, for example because the machine was destroyed, Peerlify removes it about 20 seconds after its last check-in. A runner whose Peerlify service was stopped without logging out, or that disappeared before it first checked in, stays listed until you remove it on the Devices page.
Automatic updates are turned off on the runner
So that the client isn't updated in the middle of a job, the action turns off the client's automatic updates. On a self-hosted runner this lasts after the job: the action doesn't turn them back on.
Peer names on Linux runners
Peerlify doesn't add peer names to /etc/hosts on Linux. On a Linux runner, connect to devices by address; peerlify ping and the ping input accept names. Windows runners can use names. See Finding devices by name.