CI/CD - Integrate With GitHub Actions
Introduction
This article helps you to quickly configure your project for integration with GitHub Actions.
Every templates comes with the .github/workflows/build-application.yaml file configured to build and create the application package on the Torizon Cloud.
Pre-requisites
- GitHub account
- GitHub Repository
- Torizon Cloud API v2 Client
- Torizon Cloud credentials.zip
- Project
fill-pipeline-settingstask executed at least once. See the respective Workspace Task for more information.
Configure the GitHub Repository
After creating the GitHub repository, you need to configure the secrets and variables to be used in the GitHub Actions workflow.
- In the repo page, click on the
Settingstab:

- Click on the
Secrets and variablestab:

- Click on the
Actions:

This will load the Actions secrets and variables section.
Adding Secrets
In the Actions secrets and variables section, click on the New repository secret:

This will load the New secret section. In the Name field, type the name of the secret. In the Value field, type the value of the secret. Then, click on the Add secret button:

Then, you will see the secret added to the list:

Do it for all the secrets listed below:
Torizon Cloud
-
PLATFORM_CLIENT_IDTorizon Cloud API v2 Client ID. See Creating a New Torizon Cloud API v2 Client. -
PLATFORM_CLIENT_SECRETTorizon Cloud API v2 Client Secret. See Creating a New Torizon Cloud API v2 Client.
Docker Hub (for non-TorizonCore Builder templates)
-
DOCKER_LOGINDocker Hub registry username used to push images. -
DOCKER_PASSWORDDocker Hub registry password or access token for the account used to push images.
Qt Enterprise (optional)
-
QT_LICENSE_LOGINQt Enterprise account login, required only if using Qt Enterprise packages. -
QT_LICENSE_PASSWORDQt Enterprise account password, required only if using Qt Enterprise packages.
Adding credentials.zip as CI/CD Variable
To use the TorizonCore Builder to create the Torizon Cloud package, we need the credentials.zip file available in the CI/CD pipeline. The .github/workflows/build-application.yaml expects to have the PLATFORM_CREDENTIALS secret with the base64 encode of the credentials.zip file. Execute the follow command to get the base64 encode of the credentials.zip file:
$ base64 -w 0 ./credentials.zip
Then, copy the output and paste it in the Secret* field from New secret section.
Running the GitHub Actions Workflow
After configuring the secrets, your GitHub repository is ready to run the GitHub Actions workflow. Simply push your changes to the repository and the workflow will be triggered automatically.
The following steps will be executed:
Initial Setup: This step will verify the environment variables and secrets configured in the repository. If any of the required variables or secrets are missing, the workflow will fail fast in this first step;Decode Credentials: This step will decode thePLATFORM_CREDENTIALSsecret into thecredentials.zipfile. This file is used by TorizonCore Builder to authenticate with the Torizon Cloud;Create and Publish Image: This step will run the tasktcb-platform-publishthat depends on thecreate-production-imagetask. This task will create the production image and publish it to the Torizon Cloud. See the respective Workspace Task for more information.Deploy Application: This step will run the taskplatform-update-fleet. This task will deploy the application to the Torizon Cloud fleet defined in thetcb.fleetNameproperty from.vscode/settings.json. See the respective Workspace Task for more information.
The Deploy Application step will only be executed for a push on the main branch. If you want to trigger an update when pushing in a different branch, you need to change the if condition in the Deploy Application step from the .github/workflows/build-application.yaml file. Check the templates repository file: https://github.com/toradex/vscode-torizon-templates/blob/bookworm/assets/github/workflows/build-application.yaml#L55
At the end of the pipeline, if all occurs as expected, you will have the following in the repo Actions tab:

And the Torizon Cloud update will be triggered, you should have the devices from the fleet with Update pending state:
