Skip to content

Commit

Permalink
✨ Use 'build-all-images' Makefile goal in github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Borie, Niels committed Mar 1, 2024
1 parent 86bf712 commit 4a1a025
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
28 changes: 6 additions & 22 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
run: echo ${{ steps.docker_build.outputs.digest }}
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
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
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)
Expand Down

0 comments on commit 4a1a025

Please sign in to comment.