- A GitHub Actions workflow that builds
my_appforrpi4, signs it and uploads it on every push tomain. - Two deployment groups:
qafor test devices, which gets every build, andproductionfor the rest of the fleet, which you release to by hand. - A Slack channel that hears about failed updates and unhealthy devices.
Before you start
You need:- Devices set up as in Basic Nerves device setup: they connect to the
my_appproduct in theacmeorganization, trust themy_app_keysigning key, and have taken updates through the throwawaybenchdeployment group. - The
nhCLI installed and logged in on your machine, withacmeandmy_appas its default organization and product. - The Manage or Admin role in
acme. Connecting Slack needs Admin. - The project in a GitHub repository.
rpi4.
The guide has four parts. Do them in order.
1. Build, sign and upload from CI
This part moves the build and upload to GitHub Actions. The workflow uses theupload-nerves-firmware action, which installs and runs nh for you. Nothing is released to devices yet.
The workflow needs two repository secrets and one repository variable. If your devices use a shared secret, it needs two more secrets. Add them all in GitHub under Settings > Secrets and variables > Actions.
Secret 1: an access token
In NervesHub, open the user menu, select Access tokens, click New token, enter a Note such asCI, and click Create access token. Store the value as NERVES_HUB_TOKEN. It is shown only once.
The token acts as you. See user access tokens.
Secret 2: a signing key for CI
The device guide had you createmy_app_key with nh key create. That private key is stored encrypted, and CI needs an unencrypted fwup key. So keep my_app_key for uploads from your machine, and give CI its own key, my_app_ci_key. See Sign in CI.
On your machine, generate the key and register its public half with acme. Run this outside the project directory, so the private key file cannot end up in a commit:
acme organization’s Signing keys page and click Add signing key. Enter the Name my_app_ci_key, choose the fwup (Ed25519) scheme, paste the contents of my_app_ci_key.pub into Key, and click Create Key.
Store the contents of my_app_ci_key.priv as the secret NERVES_HUB_PRIVATE_KEY.
Variable: your SSH public key
A project made bymix nerves.new reads your SSH public key from ~/.ssh when it builds, and stops if it finds none. A CI runner has none. Store the contents of the public key you use to reach your devices, such as ~/.ssh/id_ed25519.pub, as the repository variable DEVICE_SSH_PUBLIC_KEY. Variables are on the Variables tab of the same GitHub page. The workflow writes the key to ~/.ssh before it builds, so firmware built in CI accepts the same key as firmware built on your machine.
Shared secret only: the product key and secret
If you chose the Shared secret tab in the basic device guide, your config readsNERVES_HUB_PRODUCT_KEY and NERVES_HUB_PRODUCT_SECRET when the firmware is built. Store the two values you exported there as repository secrets with the same names. If your devices authenticate another way, skip this and remove the env block from the workflow’s Build firmware step.
Make devices trust the CI key
If you followed the Tip in the basic device guide and your devices already run firmware with both keys, skip to Give every build a new version.1
Add the CI public key to the firmware
Put the contents of
my_app_ci_key.pub next to the key that is already in config/target.exs:2
Release it from your machine
Bump If you already deleted
version in mix.exs. Then build, sign with the old key, and release through the bench group from the device guide:bench, leave out --deploy bench and note the UUID that nh prints. In part 2 you create qa and production from this firmware, and devices take it when they join.3
Wait for every device
Run
nh device list until every device reports the new version. Without bench, do this at the end of part 2. A device that misses this release cannot install a CI build later.Give every build a new version
NervesHub refuses a version that is not valid SemVer. A product with Require unique firmware versions turned on also refuses a version it already has for the same platform and architecture. So bumpversion in mix.exs in every change you merge to main. The setting is in product settings, and the full list of checks is in what NervesHub checks.
The workflow
Create.github/workflows/firmware.yml. Set the Erlang and Elixir versions to the ones your project uses.
uri out if you use NervesCloud. The action signs with fwup and does not install it, which is why the workflow does. Pass any other value your config reads from the environment the way the build step passes the product key and secret.
Check it works
Bump the version and push tomain. The run’s summary shows the notice Firmware <version> (<uuid>) uploaded. Then confirm NervesHub has it:
2. Tag devices and create the deployment groups
A deployment group decides which devices get which firmware, and it picks devices by tag. You make two groups:qa for your test devices and production for the rest of the fleet.
Tag the devices
Give test devices the tagqa and every other device the tag prod. A device created by the product’s shared secret starts with no tags.
- One device
- Many devices
- New devices
--tag sets the device’s whole tag list. In the web UI, edit tags on the device’s Settings tab. See Set tags.Delete the bench group
The device guide left your devices in thebench group. A device belongs to one group at most, and changing its tags does not take it out. So if bench still exists, delete it before you make the real groups:
y when nh asks you to confirm.
Create the two groups
A group is created with its first firmware, which becomes its first release. Use the firmware your devices run now, so that turning the groups on updates nothing. If the release that adds the CI key in part 1 has not gone out yet, use that firmware. Find its UUID:--version flag, a group matches devices on any firmware version. In the web UI, open Deployment groups and select New deployment group. The tag goes in Tag(s) distributed to.
Turn the groups on
A new group is off and sends nothing. Turn both on:Reconnect the devices
A device joins a group only when it connects, and only if it is in no group at that moment. Your devices were online beforeqa and production existed, so make each one reconnect:
qa to production later, replace its tag with nh device update <identifier> --tag prod. Then tick it in the Devices list, open Deployment group in the bar at the foot of the list, choose production, select Add to group, and confirm. The nh CLI cannot set a device’s group.
Pause a group
Pausing is the fastest way to stop a rollout:Check it works
deployment_group = "qa" to see exactly which devices landed there.
Go deeper: Deployment groups · Devices · Finding devices · Just-in-time provisioning · Releases · Rollout controls · Delta updates · nh command reference
3. Release every build to QA, then promote by hand
Here you make the workflow from part 1 create a release on theqa group after each upload, so your test devices update on every push to main. production stays manual: you release a build there once it has run on QA.
Release to qa from CI
Change the last step of .github/workflows/firmware.yml.
- Upload action
- nh CLI
Add the
deployment input:Promote a tested build to production
Bump the version in mix.exs, push to main, and let the qa devices run the build. When you are satisfied, release the same firmware to production.
- nh CLI
- Web UI
Find the firmware’s UUID, then create the release:
nh deployment release create as shown in Create a release.
Watch the rollout
- The group page. The badge beside the group’s name reads Rolling out and then Up to date. The Overview tab counts how many of the group’s devices are on the release’s version. The Releases tab lists every release, newest first. Open a release to see its delta updates, if it has any. If a rollout goes wrong, select Pause.
- A device. Open the device page and select the Firmware History tab. Installed firmware lists each firmware the device reported. Update attempts shows how each update ended and needs ClickHouse on the instance: see Feature prerequisites and Insights and history.
- The whole product. The Firmware bar on Insights counts devices by version, and its Failing updates list names devices that keep failing.
-
The terminal.
nh deployment showprints the group’s state, device count and current release.nh device listprints each device’s connection status and firmware version, and takes the query language of the devices page:
Check it works
- Push a commit with a new version to
mainand wait for the workflow to pass. - Run
nh deployment release list qa. The newest release, marked*, has the version you just built. - Run
nh device list --query 'deployment_group = "qa"'until your test devices report that version.
4. Send notifications to Slack
The Slack integration tells your team in a channel when an update fails or a device starts misbehaving. Your NervesHub instance must have a Slack app configured, or Slack does not appear on the Integrations page at all. See Feature prerequisites, and Create a Slack app for your instance if you host the instance yourself.Connect the workspace
You need the built-in Admin role inacme for this step. See Roles.
1
Open the Integrations page
Open the
acme organization and select the Integrations tab.2
Start the install
Click Add to Slack. If
acme already has an integration, click Add integration, then Connect a Slack workspace.3
Approve the install in Slack
Slack sends you back to the Integrations page, which now lists the workspace.
Add a channel for my_app
From here on, the Manage role is enough.
1
Add a channel
On the Integrations page, click Add integration, then Slack channel under the workspace’s name.
2
Choose the channel and product
Pick a channel under Channel. Every public channel is listed. To use a private channel, invite the app to it in Slack first.Choose Only some and select
my_app, so other products in acme stay out of this channel.3
Choose the events
Start with these four:
- Update failed: a device’s update fails, stalls, or ends with the device back on its old firmware.
- New error: a device reports an error not seen before in
my_app. This needs the Error reports extension from the basic device guide. - Health status changed: a device’s health status moves, such as from healthy to warning.
- Product notifications: anything NervesHub adds to the product’s Notifications page.
Check it works
- On the Integrations page, open the channel’s row menu and choose Send test message. A message arrives in the channel straight away, saying what the channel will get.
- In Slack, run
/nerveshub linkand follow the link it shows you. Your Slack account is then listed under Linked accounts on your NervesHub account page. See Link your Slack account.
What else Slack can do
A message about a single device has buttons to act on the device from the channel. The/nerveshub slash command looks up a device, identifies or reboots it, and runs support scripts. A link to a device or deployment group page posted in Slack gets a preview. If your team uses Microsoft Teams or Discord, both can get the same notifications, without the buttons and commands.
Go deeper: Slack · Product notifications · Microsoft Teams · Discord · Roles · Feature prerequisites · Create a Slack app for your instance
What you have now
The finished.github/workflows/firmware.yml:
NERVES_HUB_TOKEN and NERVES_HUB_PRIVATE_KEY and the repository variable DEVICE_SSH_PUBLIC_KEY. If your devices use a shared secret, it also uses the secrets NERVES_HUB_PRODUCT_KEY and NERVES_HUB_PRODUCT_SECRET.
Where to go next
- Complete fleet operations continues from here: production releases from a version tag, canaries with an approval, webhooks into your own backend, and guardrails.
- Complete Nerves device setup hardens the devices themselves: certificate authentication, control over when updates apply, and the remaining extensions.
- Rollout controls and Releases cover what a group can do beyond this guide.

