Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/balena-io-examples/community-cli-action
A community built GitHub action that allows you to use the balena CLI
https://github.com/balena-io-examples/community-cli-action
balena github-actions
Last synced: about 1 month ago
JSON representation
A community built GitHub action that allows you to use the balena CLI
- Host: GitHub
- URL: https://github.com/balena-io-examples/community-cli-action
- Owner: balena-io-examples
- License: mit
- Created: 2022-07-11T12:43:47.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T13:48:59.000Z (8 months ago)
- Last Synced: 2024-05-29T22:15:28.135Z (7 months ago)
- Topics: balena, github-actions
- Language: Shell
- Homepage:
- Size: 22.5 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Balena CLI GitHub Action
This is a community built GitHub action that allows you to use the balena CLI. You can use it to deploy to your fleet, or combine multiple CLI commands together to download an OS and preload it with your app ready for publishing as a release.
## Usage
### Deploy
Here is an example workflow.yml file that deploys to a fleet. Workflow files should be added to the `.github/workflows/` directory within your project.
```
# Full list of options available at:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actionsname: Balena Deploy
on:
pushjobs:
balena-deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3- name: balena CLI Action
uses: balena-io-experimental/[email protected]
with:
balena_token: ${{secrets.BALENA_TOKEN}}
balena_cli_commands: >
push username/your-production-fleet;
balena_cli_version: 13.7.1
```More examples can be found in the `examples` folder. If you have an example to contribute, please do raise a PR.
### Preload
If you would like to use the balena Preload functionality you can use the workflow below. Your preloaded image file will be available in the default workspace directory (./) of the GitHub workflow and can then be used to upload the preloaded image to your GitHub releases, a website or anything else you choose (consider compressing the image first).
Here is an example for creating a preloaded image and pushing as a GitHub release on your repository:
```
# Full list of options available at:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actionsname: Balena Deploy
on:
# On push of a tag
push:
tags:
- "*"jobs:
balena-deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3- name: balena CLI Action
uses: balena-io-experimental/[email protected]
with:
balena_token: ${{secrets.BALENA_TOKEN}}
balena_cli_commands: >
push my-production-repo;
os download raspberrypi4-64 --version v2.99.27 -o ./rpi-4.img;
preload rpi-4.img --fleet my-app --commit latest;
os configure rpi-4.img --config-network=ethernet --fleet my-app
balena_cli_version: 13.7.1- name: Publish release
uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: "latest"
files: |
rpi-4.img
```### Anything else
The action is simply a wrapper for the CLI so you could pass any of the CLI commands through the action and in any order to create anything you like.
## Inputs
Inputs are provided using the `with:` section of your workflow YML file.
| Key | Description | Required | Default |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------- |
| balena_token | API key to balena Cloud available from the [Balena Dashboard](https://dashboard.balena-cloud.com/preferences/access-tokens). Tokens need to be stored in GitHub as an [encrypted secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) that GitHub Actions can access. | true | |
| balena_cli_commands | CLI commands you would like to execute. Separate multiple commands with a `;`. There is an example workflow in this README. | true | |
| balena_cli_version | CLI version to use (example: `13.7.1`) | true | |
| application_path | Provide a sub-path to the location for application being deployed to BalenaCloud. Defaults to the workspace root. | false | './' |
| balena_secrets | Provide the contents of a balena secrets.json file for authenticating against private registries. | false | |## Example Balena Secrets
```
registry_secrets: |
{
"ghcr.io": {
"username": "${{ secrets.REGISTRY_USER }}",
"password": "${{ secrets.REGISTRY_PASS }}"
}
}
```