Publish Docker #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * 0" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
sdk_nrf_branch: | |
- v2.4-branch | |
- v2.2-branch | |
include: | |
- sdk_nrf_branch: v2.4-branch | |
toolchain_version: v2.4.2 | |
- sdk_nrf_branch: v2.2-branch | |
toolchain_version: v2.2.0 | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: lowercase | |
run: | | |
echo "IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" | |
- name : image-name | |
run: | | |
echo "IMAGE=$(echo ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.sdk_nrf_branch }})" >> "$GITHUB_ENV" | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build image | |
run: | | |
docker build -t ${{ env.IMAGE }} \ | |
--build-arg sdk_nrf_branch=${{ matrix.sdk_nrf_branch }} \ | |
--build-arg toolchain_version=${{ matrix.toolchain_version }} \ | |
. | |
- name: Build asset_tracker_v2 application | |
run: | | |
docker run --rm \ | |
-v ${PWD}:/workdir/project \ | |
-w /workdir/nrf/applications/asset_tracker_v2 \ | |
${{ env.IMAGE }} \ | |
west build -b nrf9160dk_nrf9160ns --build-dir /workdir/project/build -- -DEXTRA_CFLAGS="-Werror -Wno-dev" | |
- uses: actions/upload-artifact@v3 | |
with: | |
if-no-files-found: error | |
name: asset_tracker_v2-${{ matrix.sdk_nrf_branch }} | |
path: | | |
build/zephyr/merged.hex | |
build/zephyr/app_update.bin | |
- name: Ensure nrfjprog works | |
run: | | |
docker run --rm ${{ env.IMAGE }} nrfjprog -v | |
- name: Ensure clang-format works | |
run: | | |
docker run --rm ${{ env.IMAGE }} clang-format --version | |
- name: Publish image | |
run: | | |
docker images | |
docker push ${{ env.IMAGE }} |