Skip to main content
Version: 6

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​

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.

  1. In the repo page, click on the Settings tab:

alt

  1. Click on the Secrets and variables tab:

alt

  1. Click on the Actions:

alt

This will load the Actions secrets and variables section.

Adding Secrets​

In the Actions secrets and variables section, click on the New repository secret:

alt

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:

alt

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

alt

Do it for all the secrets listed below:

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 expectes 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 the PLATFORM_CREDENTIALS secret into the credentials.zip file. This file is used by TorizonCore Builder to authenticate with the Torizon Cloud;
  • Create and Publish Image: This step will run the task tcb-platform-publish that depends on the create-production-image task. 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 task platform-update-fleet. This task will deploy the application to the Torizon Cloud fleet defined in the tcb.fleetName property from .vscode/settings.json. See the respective Workspace Task for more information.
info

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:

alt

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

alt



Send Feedback!