Build, distribute and run binaries using GitHub

In this example we show how to use GitHub to deploy a binary file to your fleet of Raspberry Pis. The specific binary is written in go. The process starts by pushing the changes of your source code to your GitHub repository. Then, using GitHub actions, your source code is cross compiled for your Raspberry Pi and finally the binary is placed into your file manager. From there on you can distribute and run it on the group of devices you have specified.

If we want to build an executable (called hi-pi) for our Raspberry Pi we can use the following code


package main

import "fmt"

func main() {
    fmt.Println("Hello Norway")

we can easily do that locally using

   $ env GOARCH=arm GOOS=linux go build -o hi-pi main.go
thanks to go's powerful cross compilation capabilities.

However, we aim to setup an automatic workflow, where we

  • use git as for version control management
  • setup a GitHub runner (using GitHub actions) to build our code once a push is triggered
  • copy the created binary to the file manager via API calls
  • use the file distribution to distribute (and run) the executable on a list of devices

How to create a repository on GitHub

Check out the official documentation on how to create a repository on GitHub.

Once a repository is set up, before creating a runner you need to set up GitHub secrets as shown in the following screenshot.

GitHub secrets

There we specify our username with USERNAME_KEY and our password with PASSWORD_KEY, as we do not want them to be exposed.

After the passwords are defined we start GitHub actions which executes the YAML file on the runners on GitHub (or you can use a custom runner). GitHub actions are created under "set up a workflow yourself".

GitHub action

This is the script:

name: Go package distribution

    branches: [ master ]
    branches: [ master ]


    runs-on: ubuntu-latest
        APPNAME: hi-pi

    - uses: actions/checkout@v2

    - name: create go executable
        GOARCH: arm
        GOOS: linux
      run: go build -o $APPNAME main.go

    - name: authentication
      uses: qbee-io/authenticate-action@v1
      id: qbee-auth
        login: ${{ secrets.USERNAME_KEY }}
        password: ${{ secrets.PASSWORD_KEY }}

    - name: file upload
      uses: qbee-io/file-upload-action@v1
        token: ${{ steps.qbee-auth.outputs.token }}
        filename: ${{ env.APPNAME }}
        qbee_directory: '/'
        local_directory: '.'

Comments on the yaml file

  • this action is triggered on pushes to the master branch
  • the runner is a virtual machine with an Ubuntu OS as we specified ubuntu-latest
  • The actions/checkout@v2 option will check out your code on the virtual machine. This needs to be done every time as the virtual machine is not persistent
  • we set up a step, where we build the go application using cross compilation (due to the specified environment variables GOARCH and GOOS
  • a custom GitHub action places the output file into the file manager (within the action the REST API is used, c.f. file distribution via API)

Note that your credentials aren't revealed as we use GitHub secrets to encrypt them as you can see in the action output


Finally, we distribute our files to the remote devices as usual with the standard file distribution.

Automatic deployment

Using this workflow, every time you push your code changes to the repository the output binary (or binaries) will always be replaced within the file manager. If the binary file differs from the one previously placed in the file manager, then the file distribution is triggered along with the run command that you provided.

Hence, all your edge devices are updated by a simple git push :)