From dca6474f6ef287ca67b7afad5bf5968f688775cc Mon Sep 17 00:00:00 2001 From: Krzysztof Szyper Date: Tue, 3 Dec 2019 23:58:37 +0100 Subject: [PATCH 1/2] Added build number to Docker tags. Removed build step in pull requests. --- .github/workflows/pull_request.yml | 4 ---- .github/workflows/push.yml | 8 +++++++- Makefile | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2e669a27..ed64c6c7 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -20,7 +20,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TARGET: Dockerfile - - - name: Build Docker image (conditional) - if: github.actor == 'Krzysztof-Szyper-Epam' - run: make docker-build diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 02b32f4a..1e4c7698 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -16,7 +16,13 @@ jobs: uses: luke142367/Docker-Lint-Action@v1.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TARGET: Dockerfile + TARGET: + + - name: Generate build number + id: buildnumber + uses: einaregilsson/build-number@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image (conditional) if: github.actor == 'Krzysztof-Szyper-Epam' && github.ref == 'refs/heads/master' diff --git a/Makefile b/Makefile index b3ea02cb..fd75f5ed 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ TG_VERSION ?= latest # GitHub Actions variables GITHUB_REF ?= refs/heads/null GITHUB_SHA ?= aabbccddeeff +BUILD_NUMBER ?= 1 # Other variables and constants CURRENT_BRANCH := $(shell echo $(GITHUB_REF) | sed 's/refs\/heads\///') @@ -55,10 +56,12 @@ docker-push: docker-login ifeq ($(CURRENT_BRANCH),$(RELEASE_BRANCH)) @docker tag $(DOCKER_NAME):$(VERSION) $(DOCKER_NAME):latest @docker push $(DOCKER_NAME):latest + @docker push $(DOCKER_NAME):build-$(BUILD_NUMBER) @docker push $(DOCKER_NAME):$(VERSION) else @docker tag $(DOCKER_NAME):$(VERSION) $(DOCKER_NAME):$(CURRENT_BRANCH)-$(VERSION) @docker push $(DOCKER_NAME):$(CURRENT_BRANCH)-latest + @docker push $(DOCKER_NAME):$(CURRENT_BRANCH)-build-$(BUILD_NUMBER) @docker push $(DOCKER_NAME):$(CURRENT_BRANCH)-$(VERSION) endif From 80d7d650038b654af610a7b70717f35588f553a1 Mon Sep 17 00:00:00 2001 From: Krzysztof Szyper Date: Wed, 4 Dec 2019 00:04:15 +0100 Subject: [PATCH 2/2] Fixed target for Docker lint action. --- .github/workflows/push.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1e4c7698..8ce916ba 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -16,7 +16,6 @@ jobs: uses: luke142367/Docker-Lint-Action@v1.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TARGET: - name: Generate build number id: buildnumber