From 4a1a02569807938b366047f5b1ac65884d05203d Mon Sep 17 00:00:00 2001 From: "Borie, Niels" Date: Fri, 1 Mar 2024 18:23:17 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Use=20'build-all-images'=20Makefile?= =?UTF-8?q?=20goal=20in=20github=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_and_publish.yml | 28 ++++++------------------- Makefile | 8 ++++++- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 19d065c..308ebe8 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -6,21 +6,13 @@ on: pull_request: jobs: - build-and-push-docker-image: - name: Build Docker image and push to repositories + build-and-push-docker-images: + name: Build and push Docker images runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - - name: Prepare tag - id: prep - run: | - DOCKER_IMAGE=nielsborie/machine-learning-environments - VERSION=`cat ./SNAPSHOT.txt` - TAGS="${DOCKER_IMAGE}:${VERSION}" - echo ::set-output name=tags::${TAGS} - - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: @@ -36,17 +28,9 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5 - with: - builder: ${{ steps.buildx.outputs.name }} - context: "{{defaultContext}}:advanced" - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max + - name: Build and push image + run: | + make build-all-images - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Makefile b/Makefile index 29b9d5a..2f9bafa 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -BRANCH_NAME ?= $(shell git branch | grep \* | cut -d ' ' -f2) +#BRANCH_NAME ?= $(shell git branch | grep \* | cut -d ' ' -f2) PROJECT_NAME ?= machine-learning-environments GIT_COMMIT ?= $(shell git rev-parse HEAD) PYTHON_INTERPRETER = python3 @@ -7,6 +7,12 @@ PYTHON_VERSION ?= 3.11 OS_NAME = $(shell uname) REGISTRY_URL ?= nielsborie +ifdef GITHUB_ACTIONS + BRANCH_NAME ?= $(shell echo "${GITHUB_REF}" | awk -F'/' '{print $$3}') +else + BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main") +endif + ifeq ($(BRANCH_NAME),main) IMAGE_VERSION := v$(shell cat ./VERSION.txt) else ifeq ($(BRANCH_NAME),develop)