0.1.0-klutchell-pin-versions-03055b3b36d42547c30b200412ccb52aba909efa • Published 3 years ago

balena-ci v0.1.0-klutchell-pin-versions-03055b3b36d42547c30b200412ccb52aba909efa

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

Balena CI Github Action

This action allows you to send some source to Balena builders. Depending on the context available to the action, it will either make your release a draft or not.

Usage

Here is an example workflow.yml file. See our workflows section to understand it some more.

on:
 pull_request:
    types: [opened, synchronize, closed]
    branches:
      - master

jobs:
  balena_cloud_build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: balena-io/balena-ci@master
        id: build
        with:
          balena_token: ${{ secrets.BALENA_TOKEN }}
          fleet: my_org/sample_fleet
      - name: Log release ID built
        run: echo "Built release ID ${{ steps.build.outputs.release_id }}"

Inputs

keyDescriptionRequiredDefault
balena_tokenAPI key to balenaCloudtrue
fleetThe slug of the fleet (eg: my_org/sample_fleet) for which the release is fortrue
environmentDomain of API hosting your fleetsfalsebalena-cloud.com
versionbotTells action to use Versionbot branch for versioningfalsefalse

environment can be used to specify a custom domain for the backend that will build and deploy your release. If for example you want to deploy to staging environment, you would set it to balena-staging.com or if you run your own instance of balenaCloud such as openBalena then specify your domain here.

Outputs

keyDescriptionNullable
release_idID of the release builttrue

The release_id output could be null because the action might just finalize previously built releases.

Workflows

This action is leveraging the is_final trait of a release to enable you to develop releases in a way that make it easier to test.

With this value, we can mark a release as draft so that it is built and available to your devices to be tested but any device tracking latest won't upgrade to it!

Draft release workflow (recommended)

In the sample config shown above under usage we are triggering the action to run on pull_request events: opened, synchronize, and closed. This allows us to build releases as a draft when a new pull request is opened and whenever it gets updated. The draft release will be available for you to pin devices to and test out then, once the pull request has become merged the closed event is triggered. This time the action will know that it just has to mark the previously built draft release as final.

Now, devices tracking latest will automatically download the release and this was all powered through your github workflow!

Commit to master

This workflow is useful if you push directly to master. This workflow will build your release and notice that it is merging directly to the default branch so not build them as drafts. Devices tracking latest will automatically download these new releases.

To use this workflow just replace the events found from the sample workflow config under usage with:

on:
  push:
    branches:
      - master

Additional comments about workflows

If you need to build a release for multiple fleets across several environments (balena-cloud.com, balena-staging.com, etc) you can create multiple workflow files for each environment and use a matrix to pass a list of fleet names into 1 job. See how Balena's Supervisor does this with the staging deployment workflow.

Development

See the development docs.