Skip to content

Build, Test and Publish the Network License Manager Container #36

Build, Test and Publish the Network License Manager Container

Build, Test and Publish the Network License Manager Container #36

# Copyright 2024 The MathWorks, Inc.
name: Build, Test and Publish the Network License Manager Container
# Trigger this workflow either manually or when a new change is pushed to the
# repo (except .md files)
on:
workflow_dispatch:
# Run workflow when there is a push to the 'main' branch & push includes changes to any files in described path
push:
branches:
- 'main'
paths:
- 'network-license-manager/**'
schedule:
# Run at 00:00 on every Monday (1st Day of the Week)
- cron: "0 0 * * 1"
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/network-license-manager
LICENSE_FILE_PATH: ${{ github.workspace }}/licenses/license.dat
HOSTNAME: docker-server
MAC_ADDRESS: ${{ secrets.NLM_CONTAINER_TEST_MAC_ADDRESS }}
PORT: 27012
MATLAB_RELEASE: latest
jobs:
build-test-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image locally
uses: docker/build-push-action@v5
with:
context: ./network-license-manager
platforms: linux/amd64
load: true
tags: |
${{ env.IMAGE_NAME }}:latest
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install test dependencies
working-directory: ./network-license-manager/tests
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Generate license file
env:
MATLAB_LICENSE_FILE: ${{ secrets.MATLAB_LICENSE_FILE_R2024B }}
working-directory: ./network-license-manager/tests
run: ./setup_gen_licfile.sh
- name: Test container
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}:latest
working-directory: ./network-license-manager/tests
run: python -m unittest
- name: Push the image to ghcr.io
run: docker push ${{ env.IMAGE_NAME }}:latest