Skip to content

Merge pull request #34 from vsaw/602-update-nodejs-18 #72

Merge pull request #34 from vsaw/602-update-nodejs-18

Merge pull request #34 from vsaw/602-update-nodejs-18 #72

Workflow file for this run

name: CI/CD
# Trigger the workflow on push or pull request
# Run on all branches and pull request except gh-pages which has it's own action
on:
push:
branches-ignore:
- 'gh-pages'
pull_request:
branches-ignore:
- 'gh-pages'
release:
types: [created]
jobs:
# Build docker images
build-docker-and-publish:
runs-on: ubuntu-latest
# needs: build-and-test-code
env:
# Only publish to Docker Hub if the dockerhub username is set, and either happens
#
# - we have a change in the development branch
# - we have a new tag
DOCKERHUB_PUBLISH: ${{ (github.event_name == 'push' && (github.event.ref == 'refs/heads/development' || startsWith(github.event.ref, 'refs/tags/')) || github.event_name == 'release') && secrets.DOCKERHUB_USERNAME != '' }}
# In case we run a pull request, the secrets are not available to us. Therefore check first
# and assign a 'dummy' dockerhub username
DOCKERHUB_USERNAME: ${{ ( secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_USERNAME ) || 'dummy' }}
strategy:
matrix:
include:
- platform: desktop
docker-platform: linux/amd64
- platform: xavier
docker-platform: linux/arm64
- platform: nano
docker-platform: linux/arm64
- platform: cpu-amd64
docker-platform: linux/amd64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_PUBLISH == 'true' }}
continue-on-error: true
uses: docker/login-action@v2
with:
# Use the secrets directly and not the validated environment DOCKERHUB_USERNAME
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Determine dockerhub tag
id: dockerhub-tag
# Determine the dockerhub tag based on if our current working tree points to a tag or not
# the tags will either be `<tag>-<platform>` or `development-<platform>`
run: |
GIT_TAG=$(git tag -l --points-at $(git log -n 1 --format=%H))
if [ ! -z $GIT_TAG ]; then
echo "dockerhub-tag=$GIT_TAG-${{ matrix.platform }}" >> $GITHUB_OUTPUT
else
echo "dockerhub-tag=development-${{ matrix.platform }}" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./
file: docker/build/${{ matrix.platform }}/Dockerfile
platforms: ${{ matrix.docker-platform }}
push: ${{ env.DOCKERHUB_PUBLISH == 'true' }}
tags: ${{ env.DOCKERHUB_USERNAME }}/darknet:${{ steps.dockerhub-tag.outputs.dockerhub-tag }}