How to pin a device to release from Github Actions?

Is there a way to use a token from Github Actions to dynamically pin a device to a release?

This is useful for automating testing through a balena virtual machine.

It is available through Balena CLI it seemsā€¦

You could do it by using the Balena CLI on GitHub actions. Either by using an action such asā€¦

Or you could just manually install it as part of the action in a previous stepā€¦

2 Likes

Thanks @shawaj! Yea, I already rely heavily on Github Actions for working with Balena, You can see my workflows here: edt-offline/.github at main Ā· digidem/edt-offline Ā· GitHub

Unfortunately is seems weā€™re only able to pin entire fleets, not single devices through the Balena cli.

@luandro as I understand it, you can do individual devices as well. Itā€™s just not documented in the balena documentation.

But I believe if you use the Balena CLI help function it shows as available there

@shawaj doesnā€™t seem like it. Not even fleet pin is documented on cliā€™s help. My intuition says it should be something like: balena device <uid> pin <release>

Any other commands I should try to see if this exists?

Iā€™ve created an issue for this.

So it looks like the command is balena device pin <uuid> [releaseToPinTo]

See here full output of balena help --verbose:

% balena help --verbose
USAGE
$ balena [COMMAND] [OPTIONS]

PRIMARY COMMANDS
  login                                  login to balena
  push <fleetOrDevice>                   build release images on balenaCloud servers or on a local mode device
  logs <device>                          show device logs
  ssh <fleetOrDevice> [service]          open a SSH prompt on a device's host OS or service container
  fleets                                 list all fleets
  fleet <fleet>                          display information about a single fleet
  devices                                list all devices
  device <uuid>                          show info about a single device
  tunnel <deviceOrFleet>                 tunnel local ports to your balenaOS device
  preload <image>                        preload a release on a disk image (or Edison zip archive)
  build [source]                         build a project locally
  deploy <fleet> [image]                 deploy a single image or a multicontainer project to a balena fleet
  join [deviceIpOrHostname]              move a local device to a fleet on another balena server
  leave [deviceIpOrHostname]             remove a local device from its balena fleet
  scan                                   scan for balenaOS devices on your local network

ADDITIONAL COMMANDS
  api-key generate <name>                generate a new balenaCloud API key
  config generate                        generate a config.json file
  config inject <file>                   inject a config.json file to a balenaOS image or attached media
  config read                            read the config.json file of a balenaOS image or attached media
  config reconfigure                     interactively reconfigure a balenaOS image file or attached media
  config write <key> <value>             write a key-value pair to the config.json file of an OS image or attached media
  device deactivate <uuid>               deactivate a device
  device identify <uuid>                 identify a device
  device init                            initialize a device with balenaOS
  device local-mode <uuid>               get or manage the local mode status for a device
  device move <uuid(s)>                  move one or more devices to another fleet
  device os-update <uuid>                start a Host OS update for a device
  device pin <uuid> [releaseToPinTo]     pin a device to a release
  device public-url <uuid>               get or manage the public URL for a device
  device purge <uuid>                    purge data from a device
  device reboot <uuid>                   restart a device
  device register <fleet>                register a new device
  device rename <uuid> [newName]         rename a device
  device restart <uuid>                  restart containers on a device
  device rm <uuid(s)>                    remove one or more devices
  device shutdown <uuid>                 shutdown a device
  device track-fleet <uuid>              make a device track the fleet's pinned release
  devices supported                      list the supported device types (like 'raspberrypi3' or 'intel-nuc')
  env add <name> [value]                 add env or config variable to fleets, devices or services
  env rename <id> <value>                change the value of a config or env var for a fleet, device or service
  env rm <id>                            remove a config or env var from a fleet, device or service
  envs                                   list the environment or config variables of a fleet, device or service
  fleet create <name>                    create a fleet
  fleet pin <slug> [releaseToPinTo]      pin a fleet to a release
  fleet purge <fleet>                    purge data from a fleet
  fleet rename <fleet> [newName]         rename a fleet
  fleet restart <fleet>                  restart a fleet
  fleet rm <fleet>                       remove a fleet
  fleet track-latest <slug>              make this fleet track the latest release
  key <id>                               display an SSH key
  key add <name> [path]                  add an SSH key to balenaCloud
  key rm <id>                            remove an SSH key from balenaCloud
  keys                                   list the SSH keys in balenaCloud
  local configure <target>               (Re)configure a balenaOS drive or image
  local flash <image>                    flash an image to a drive
  logout                                 logout from balena
  note <|note>                           set a device note
  orgs                                   list all organizations
  os build-config <image> <device-type>  prepare a configuration file for use by the 'os configure' command
  os configure <image>                   configure a previously downloaded balenaOS image
  os download <type>                     download an unconfigured OS image
  os initialize <image>                  initialize an os image for a device
  os versions <type>                     show available balenaOS versions for the given device type
  release <commitOrId>                   get info for a release
  release finalize <commitOrId>          finalize a release
  release invalidate <commitOrId>        invalidate a release
  release validate <commitOrId>          validate a release
  releases <fleet>                       list all releases of a fleet
  settings                               print current settings
  support <action>                       grant or revoke support access for devices or fleets
  tag rm <tagKey>                        remove a tag from a fleet, device or release
  tag set <tagKey> [value]               set a tag on a fleet, device or release
  tags                                   list all tags for a fleet, device or release
  util available-drives                  list available drives
  version                                display version information for the balena CLI and/or Node.js
  whoami                                 display account information for current user

GLOBAL OPTIONS
  --help, -h                             display command help
  --debug                                enable debug output
  --unsupported                          prevent exit with an error as per Deprecation Policy
                                         See: https://git.io/JRHUW#deprecation-policy

Deprecation Policy Reminder
The balena CLI enforces its deprecation policy by exiting with an error a year
after the release of the next major version, unless the --unsupported option is
used. Find out more at: https://git.io/JRHUW#deprecation-policy

For further help or support, visit:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting

Perfect, thanks @shawaj!

1 Like

No probs :raised_hands: