Skip to content

Build and Run

Build and Run #33

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
MQTT_BROKER_ENDPOINT: ${{ secrets.MQTT_BROKER_ENDPOINT }}
IOT_THING_NAME: ${{ secrets.IOT_THING_NAME }}
CLIENT_CERTIFICATE_PEM: ${{ secrets.CLIENT_CERTIFICATE_PEM }}
CLIENT_PRIVATE_KEY_PEM: ${{ secrets.CLIENT_PRIVATE_KEY_PEM }}
run: |
pushd amazon-freertos/demos/include/
# Add the Client-Certificate Client-Private-Key in aws_clientcredential_keys.h
cp aws_clientcredential_keys.h aws_clientcredential_keys.h.in
sed -i 's|\(#define keyCLIENT_CERTIFICATE_PEM \).*NULL|\1 ${CLIENT_CERTIFICATE_PEM}|' aws_clientcredential_keys.h.in
sed -i 's|\(#define keyCLIENT_PRIVATE_KEY_PEM \).*NULL|\1 ${CLIENT_PRIVATE_KEY_PEM}|' aws_clientcredential_keys.h.in
envsubst < aws_clientcredential_keys.h.in > aws_clientcredential_keys.h
# Add the Client-Credentials in aws_clientcredential.h
cp aws_clientcredential.h aws_clientcredential.h.in
sed -i 's|\(#define clientcredentialMQTT_BROKER_ENDPOINT \).*""|\1 "${MQTT_BROKER_ENDPOINT}"|' aws_clientcredential.h.in
sed -i 's|\(#define clientcredentialIOT_THING_NAME \).*""|\1 "${IOT_THING_NAME}"|' aws_clientcredential.h.in
envsubst < aws_clientcredential.h.in > aws_clientcredential.h
popd
# 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 "\[iot_thread\] \[INFO\] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess." ./out/Demo/AWS_MQTT_Demo.log)" -eq 0 ]
then
exit 1
else
exit 0
fi