From f6ea68bc0c0dd37e38216f3ce1c6cbf3a0c3bdc4 Mon Sep 17 00:00:00 2001 From: Krzysztof Szyper Date: Tue, 3 Dec 2019 20:53:42 +0100 Subject: [PATCH] Added workflow for pull requests. Enabled docker-linting. --- .github/workflows/feature.yml | 24 ++++++++++++++++++++++ .github/workflows/{main.yml => master.yml} | 13 +++++++++--- Makefile | 7 ++++--- README.md | 3 ++- 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/feature.yml rename .github/workflows/{main.yml => master.yml} (57%) diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml new file mode 100644 index 00000000..4f700a7e --- /dev/null +++ b/.github/workflows/feature.yml @@ -0,0 +1,24 @@ +name: Build on pull request + +on: + pull_request: + types: + - opened + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Docker Lint + uses: luke142367/Docker-Lint-Action@v1.0.0 + with: + target: Dockerfile + + - name: Build Docker image + if: github.actor != 'Krzysztof-Szyper-Epam' + run: make docker-build diff --git a/.github/workflows/main.yml b/.github/workflows/master.yml similarity index 57% rename from .github/workflows/main.yml rename to .github/workflows/master.yml index fd1b8df8..ed1e1311 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/master.yml @@ -1,6 +1,9 @@ -name: Build and Push to DockerHub +name: Build and push to Docker Hub -on: [push] +on: + push: + branches: + - master jobs: build: @@ -9,8 +12,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v1 + - name: Docker Lint + uses: luke142367/Docker-Lint-Action@v1.0.0 + with: + target: Dockerfile + - name: Build and Push Docker image env: - DOCKER_USER_ID: ${{ secrets.DOCKER_USER_ID }} DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} run: make build-and-push diff --git a/Makefile b/Makefile index f2daf20e..b3ea02cb 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ GITHUB_SHA ?= aabbccddeeff CURRENT_BRANCH := $(shell echo $(GITHUB_REF) | sed 's/refs\/heads\///') GITHUB_SHORT_SHA := $(shell echo $(GITHUB_SHA) | cut -c1-7) RELEASE_BRANCH := master +DOCKER_USER_ID := christophshyper DOCKER_NAME := christophshyper/docker-terragrunt get-versions: @@ -36,9 +37,6 @@ endif $(info Current branch: $(CURRENT_BRANCH)) $(info Commit hash: $(GITHUB_SHORT_SHA)) -docker-login: - @echo $(DOCKER_TOKEN) | docker login -u $(DOCKER_USER_ID) --password-stdin - docker-build: get-versions @docker rm $(DOCKER_NAME):latest || true @docker rm $(DOCKER_NAME):$(VERSION) || true @@ -50,6 +48,9 @@ docker-build: get-versions --file=Dockerfile \ --tag=$(DOCKER_NAME):$(VERSION) . +docker-login: + @echo $(DOCKER_TOKEN) | docker login -u $(DOCKER_USER_ID) --password-stdin + docker-push: docker-login ifeq ($(CURRENT_BRANCH),$(RELEASE_BRANCH)) @docker tag $(DOCKER_NAME):$(VERSION) $(DOCKER_NAME):latest diff --git a/README.md b/README.md index bdf6b824..fc8d4833 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Docker image with Terraform/Terragrunt and all needed components to easily manage AWS infrastructure. [![GitHub krzysztof-szyper-epam/docker-terragrunt](https://img.shields.io/badge/github-krzysztof--szyper--epam%2Fdocker--terragrunt-blue.svg)](https://github.com/krzysztof-szyper-epam/docker-terragrunt "shields.io") -[![Actions Status](https://github.com/Krzysztof-Szyper-Epam/docker-terragrunt/workflows/Build%20and%20Push%20to%20DockerHub/badge.svg)](https://github.com/Krzysztof-Szyper-Epam/docker-terragrunt/actions "github.com") +[![Actions Status](https://github.com/Krzysztof-Szyper-Epam/docker-terragrunt/workflows/Build%20and%20push%20to%20Docker%20Hub/badge.svg)](https://github.com/Krzysztof-Szyper-Epam/docker-terragrunt/actions?query=workflow%3A%22Build+and+push+to+Docker+Hub%22 "github.com") +[![Actions Status](https://github.com/Krzysztof-Szyper-Epam/docker-terragrunt/workflows/Build%20on%20pull%20request/badge.svg)](https://github.com/Krzysztof-Szyper-Epam/docker-terragrunt/actions?query=workflow%3A%22Build+on+pull+request%22 "github.com") ![GitHub](https://img.shields.io/github/license/krzysztof-szyper-epam/docker-terragrunt "shields.io") ![GitHub last commit](https://img.shields.io/github/last-commit/krzysztof-szyper-epam/docker-terragrunt "shields.io")