Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to auto-deploy an OTA update #17

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/ota-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: WeFault Fleet Build & OTA Deploy
run-name: ${{ inputs.run_name }}

env:
DEFAULT_PYTHON: 3.8

# These parameters are used for OTA payload upload and release deployment
MEMFAULT_PROJECT: thingy91-fleet
gminn marked this conversation as resolved.
Show resolved Hide resolved
MEMFAULT_ORG: memfault
HARDWARE_VERSION: thingy91
SOFTWARE_VERSION: "$(date --iso-8601 | tr - .).${GITHUB_RUN_ID}"
gminn marked this conversation as resolved.
Show resolved Hide resolved
SOFTWARE_TYPE: nrf91ns-fw
COHORT: auto-ota

on:
push:
branches:
- main
workflow_dispatch:
inputs:
run_name:
description: 'Name of run to identify it from other runs'
required: false
type: string

jobs:
ota-deploy:
runs-on: ubuntu-latest

# Image generated from: https://github.com/memfault/memfault-port-playground/tree/master/docker/nrf-connect-sdk
container:
image: memfault/nrf-connect-sdk:2024-01-05
gminn marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Install Zephyr SDK as CMake package
run: |
${ZEPHYR_SDK_INSTALL_DIR}/setup.sh -c

- name: Build OTA payload
run: |
cd $GITHUB_WORKSPACE
cd ../
python -m venv venv
. venv/bin/activate
pip install -U pip==21.1
pip install west==1.2.0 memfault-cli==1.0.4
west init -l memfault-asset-tracker
west update --narrow -o=--depth=1 -o=--recurse-submodules --path-cache ~/zephyr-thingy91-path-cache
pip install -r zephyr/scripts/requirements.txt
pip install -r nrf/scripts/requirements-build.txt
west build -b thingy91_nrf9160_ns -p always memfault-asset-tracker -- \
-DCONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.THINGY91_OTA_PROJECT_KEY }}\" \
-DOVERLAY_CONFIG=overlay-memfault.conf \
-DCONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y \
-DCONFIG_MEMFAULT_NCS_FW_VERSION=\"${{ env.SOFTWARE_VERSION }}\"

rm -rf ~/zephyr-thingy91-path-cache
cp -r ${PWD} ~/zephyr-thingy91-path-cache

- name: Update Zephyr Project Cache
uses: actions/cache@v3
with:
path: ~/zephyr-thingy91-path-cache
key: zephyr-thingy91-{{ checksum $GITHUB_WORKSPACE/west.yml }}

- name: Upload payload and deploy release
run: |
cd $GITHUB_WORKSPACE
cd ../
. venv/bin/activate
memfault \
--org-token ${{ secrets.THINGY91_OTA_ORG_TOKEN }} \
--org ${{ env.MEMFAULT_ORG }} \
--project ${{ env.MEMFAULT_PROJECT }} \
upload-mcu-symbols build/zephyr/zephyr.elf

memfault \
--org-token ${{ secrets.THINGY91_OTA_ORG_TOKEN }} \
--org ${{ env.MEMFAULT_ORG }} \
--project ${{ env.MEMFAULT_PROJECT }} upload-ota-payload \
--hardware-version ${{ env.HARDWARE_VERSION }} \
--software-type ${{ env.SOFTWARE_TYPE }} \
--software-version ${{ env.SOFTWARE_VERSION }} \
build/zephyr/app_update.bin

memfault \
--org-token ${{ secrets.THINGY91_OTA_ORG_TOKEN }} \
--org ${{ env.MEMFAULT_ORG }} \
--project ${{ env.MEMFAULT_PROJECT }} deploy-release \
--release-version ${{ env.SOFTWARE_VERSION }} \
--cohort ${{ env.COHORT }}