Skip to content

Build and Run

Build and Run #39

Workflow file for this run

name: MQTT2AWS
on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- ./**
push:
branches: [main]
paths:
- ./**
schedule:
- cron: '00 22 * * 0'
# A new triggered workflow run will interrupt an existing workflow run
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
# https://github.com/ARM-software/cmsis-actions
- name: Activate vcpkg
uses: ARM-software/cmsis-actions/vcpkg@v1
with:
config: "./vcpkg-configuration.json"
# https://github.com/ARM-software/cmsis-actions
- name: Activate Arm tool license
uses: ARM-software/cmsis-actions/armlm@v1
# Configure AWS IoT Thing Credentials
- name: Configure AWS IoT Thing Credentials
env:
# Get the secrets from the Github
IOT_THING_NAME: ${{ secrets.IOT_THING_NAME }}
MQTT_BROKER_ENDPOINT: ${{ secrets.MQTT_BROKER_ENDPOINT }}
ROOT_CA_PEM: ${{ secrets.ROOT_CA_PEM }}
CLIENT_CERTIFICATE_PEM: ${{ secrets.CLIENT_CERTIFICATE_PEM }}
CLIENT_PRIVATE_KEY_PEM: ${{ secrets.CLIENT_PRIVATE_KEY_PEM }}
run: |
DEMO_CONFIG="FreeRTOS-Plus/Demo/Config/demo_config.h"
cp "$DEMO_CONFIG" "${DEMO_CONFIG}.in"
# Activate the define by replacing the placeholder with the actual value.
activate_define() {
local define_name="$1"
local define_value="$2"
sed -i "/^[[:space:]]*\* #define ${define_name}/{N;s|^[[:space:]]*\* #define .*\n[[:space:]]*\*/| */\n#define ${define_name} ${define_value}|;}" "${DEMO_CONFIG}.in"
}
activate_define democonfigCLIENT_IDENTIFIER '"${IOT_THING_NAME}"'
activate_define democonfigMQTT_BROKER_ENDPOINT '"${MQTT_BROKER_ENDPOINT}"'
activate_define democonfigROOT_CA_PEM '${ROOT_CA_PEM}'
activate_define democonfigCLIENT_CERTIFICATE_PEM '${CLIENT_CERTIFICATE_PEM}'
activate_define democonfigCLIENT_PRIVATE_KEY_PEM '${CLIENT_PRIVATE_KEY_PEM}'
envsubst < "${DEMO_CONFIG}.in" > "$DEMO_CONFIG"
# Build the executable
- name: Build executable
run: |
cbuild Demo.csolution.yml --packs --context .Debug+AVH --rebuild
# Execute the demo
- name: Execute AWS_MQTT demo
run: |
FVP_Corstone_SSE-300 \
-a ./out/Demo/AVH/Debug/Demo.axf \
-f ./Board/AVH_MPS3_Corstone-300/fvp_config.txt \
--simlimit 120 --stat -Q 10 > ./out/Demo/AWS_MQTT_Demo.log
cat ./out/Demo/AWS_MQTT_Demo.log
# Upload the AWS_MQTT_Demo.log to artifact.
# Set the maximum retention period of 1 day.
- name: Upload the AWS_MQTT_Demo.log
uses: actions/upload-artifact@v7
with:
name: AWS_MQTT_Demo.log
path: ./out/Demo/AWS_MQTT_Demo.log
retention-days: 1
# Analyze results
- name: Analyze results
run: |
echo "Checking if a MQTT packet has been received"
if [ "$(grep -c "Incoming Publish Message : Hello World!" ./out/Demo/AWS_MQTT_Demo.log)" -eq 0 ]
then
exit 1
else
exit 0
fi