From b1750866e20a3af565fd0a362f03ec4ce50ce285 Mon Sep 17 00:00:00 2001 From: "aleksandr.vodyanov" Date: Tue, 8 Oct 2024 13:11:27 +0300 Subject: [PATCH] update-gitea-actions (!2) Reviewed-on: https://git.avroid.tech/Templates/template-docker-repository/pulls/2 Co-authored-by: aleksandr.vodyanov Co-committed-by: aleksandr.vodyanov --- .gitea/workflows/build-and-push-image.yaml | 18 +++++++++++++----- Makefile | 11 +++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/build-and-push-image.yaml b/.gitea/workflows/build-and-push-image.yaml index c94e276..1017f63 100644 --- a/.gitea/workflows/build-and-push-image.yaml +++ b/.gitea/workflows/build-and-push-image.yaml @@ -1,9 +1,9 @@ name: Build and publish docker image -on: - push: - branches: - - master +on: [push] + +env: + CI: ON # Allow workflow to be manually run from the Gitea UI workflow_dispatch: @@ -27,10 +27,17 @@ jobs: - name: Check out repository code uses: actions/checkout@v3 - - name: "Build image and push" + - name: "Build image" run: | make build + + - name: "Push image" + run: | make push + if: ${{ gitea.ref == 'refs/heads/master' }} + + - name: "Clear image" + run: | make clean - name: Create and push tag @@ -39,3 +46,4 @@ jobs: git config user.email "svc-jenkins@avroid.tech" git tag $(make getTag) git push origin $(make getTag) + if: ${{ gitea.ref == 'refs/heads/master' }} diff --git a/Makefile b/Makefile index 77227e2..1feeb2f 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,12 @@ IMAGE_TAG = 1.0 REVISION = DOCKER_REGISTRY = harbor.avroid.tech +CI_FLAGS = + +ifeq ($(CI), false) + CI_FLAGS = --no-cache +endif + all: @echo 'DEFAULT:' @echo ' make build' @@ -14,15 +20,12 @@ all: @echo ' make clean' build: - DOCKER_BUILDKIT=1 docker build \ + DOCKER_BUILDKIT=1 docker build $(CI_FLAGS) \ -f Dockerfile \ --platform linux/amd64 \ -t $(DOCKER_REGISTRY)/$(IMAGE_GROUP)/$(IMAGE_NAME):$(IMAGE_TAG)$(REVISION) src/ push: -ifeq ($(CI), false) - docker login https://$(DOCKER_REGISTRY) -endif docker push $(DOCKER_REGISTRY)/$(IMAGE_GROUP)/$(IMAGE_NAME):$(IMAGE_TAG)$(REVISION) getTag: