Merge pull request #462 from mtconnect/460_461_mqtt_adapter_issues #28
Workflow file for this run
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
# build docker image and push to docker hub | |
# note: this won't work because the cross-platform build takes around 10h, | |
# but github limits us to 6h. | |
# so need to build it locally and push to docker hub. | |
# see Dockerfile for instructions. | |
# needs github secrets set for - | |
# DOCKERHUB_USERNAME - ie mtconnect | |
# DOCKERHUB_TOKEN - token for that account | |
# Set VERSION below before building. | |
# See CMakeLists.txt for the current version. | |
# Note: this will tag the image with that version, as well as 'latest'. | |
name: Build Docker image | |
env: | |
PLATFORMS: linux/amd64,linux/arm64 | |
# when to run workflow | |
on: | |
# # run on push or pull request events for the master branch | |
push: | |
tags: | |
- "v*.*.*" | |
# allows you to run this workflow manually from the actions tab | |
workflow_dispatch: | |
# a workflow run has one or more jobs that can run sequentially or in parallel | |
jobs: | |
# this workflow contains a single job called "build" | |
build: | |
# the type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
include: | |
- dockerfile: docker/alpine/Dockerfile | |
name: agent | |
- dockerfile: demo/Dockerfile | |
name: demo | |
# steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# checks-out your repository under $GITHUB_WORKSPACE | |
# see https://github.com/actions/checkout | |
- name: Checkout Agent | |
uses: actions/checkout@v3 | |
# the QEMU emulator lets us build for arm processors also | |
# see https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU emulator | |
uses: docker/setup-qemu-action@v3 | |
# see https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Remove leading v from the version | |
run: | | |
echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> $GITHUB_ENV | |
echo "MAJOR_VERSION=$(echo ${{ github.ref_name }} | sed -E 's/^v([0-9]+)\.([0-9]+)\..+/\1.\2/')" >> $GITHUB_ENV | |
# see https://github.com/docker/build-push-action | |
- name: Build image and push to DockerHub | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
platforms: ${{ env.PLATFORMS }} | |
# docker hub user/repo:tag | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.name }}:latest | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.name }}:${{ env.VERSION }} | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.name }}:${{ env.MAJOR_VERSION }} | |
# push to docker hub | |
push: true |