Skip to content

Commit

Permalink
Merge pull request #8 from Senzing/issue-5.bryan-nice
Browse files Browse the repository at this point in the history
Issue 5.bryan nice
  • Loading branch information
Bryan Nice authored Feb 24, 2020
2 parents 5d2e58e + 89ff1a0 commit 53afce9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pull-request-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ jobs:
run: git merge origin/master
- name: Build Docker Image
id: build_docker_image
run: make docker-build

run: |
make \
GITHUB_HEAD_REF=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}} \
GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME} \
docker-build
6 changes: 5 additions & 1 deletion .github/workflows/push-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ jobs:
run: git checkout origin/${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
- name: Build Docker Image
id: build_docker_image
run: make docker-build
run: |
make \
GITHUB_HEAD_REF=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}} \
GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME} \
docker-build
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added to 1.1.0

- Ability to attach files to the Jira Issue
- Update make file so it can be used both by the Git Actions pipeline and directly
- Docker file to include the default Git Actions workspace so it can be leveraged to interact with the runner's workspace during a CI/CD pipeline.

## [1.0.0] - 2020-01-11
Expand Down
34 changes: 10 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

GIT_REPOSITORY_NAME := $(shell basename `git rev-parse --show-toplevel`)
GIT_VERSION := $(shell git describe --always --tags --long --dirty | sed -e 's/\-0//' -e 's/\-g.......//')
GITHUB_HEAD_REF ?= "master"
GITHUB_EVENT_NAME ?= "push"

# -----------------------------------------------------------------------------
# Functions
Expand Down Expand Up @@ -32,43 +34,27 @@ build: fmt
.PHONY: default
default: help

# -----------------------------------------------------------------------------
# Copy files to docker build folder
# -----------------------------------------------------------------------------
.PHONY: copy-docker-files
copy-docker-files:
@mkdir -p build/docker/$(GIT_REPOSITORY_NAME)
@cp Makefile LICENSE README.md main.go go.mod go.sum build/docker/$(GIT_REPOSITORY_NAME)
@cp -r configuration build/docker/$(GIT_REPOSITORY_NAME)

.PHONY: delete-docker-files
delete-docker-files:
@rm -rf build/docker/$(GIT_REPOSITORY_NAME)

# -----------------------------------------------------------------------------
# Docker-based build
# -----------------------------------------------------------------------------

.PHONY: docker
docker: docker-rmi-for-build
.PHONY: docker-build
docker-build: docker-rmi-for-build
docker build \
--build-arg GITHUB_HEAD_REF=$(GITHUB_HEAD_REF) \
--build-arg GITHUB_EVENT_NAME=$(GITHUB_EVENT_NAME) \
--tag $(GIT_REPOSITORY_NAME) \
--tag $(GIT_REPOSITORY_NAME):$(GIT_VERSION) \
--build-arg GO_BUILD_FILES=$(GIT_REPOSITORY_NAME) \
build/docker

.PHONY: docker-development-cache
docker-development-cache: docker-rmi-for-build-development-cache
.PHONY: docker-build-development-cache
docker-build-development-cache: docker-rmi-for-build-development-cache
docker build \
--build-arg GITHUB_HEAD_REF=$(GITHUB_HEAD_REF) \
--build-arg GITHUB_EVENT_NAME=$(GITHUB_EVENT_NAME) \
--tag $(GIT_REPOSITORY_NAME):$(GIT_VERSION) \
build/docker

.PHONY: docker-build
docker-build: copy-docker-files docker delete-docker-files

.PHONY: docker-build-development-cache
docker-build-development-cache: copy-docker-files docker-development-cache delete-docker-files

# -----------------------------------------------------------------------------
# Clean up targets
# -----------------------------------------------------------------------------
Expand Down
18 changes: 14 additions & 4 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# -----------------------------------------------------------------------------
FROM golang:1.13.4-alpine3.10 as BUILD

ARG GO_BUILD_FILES=git-action-jira-issue-creation
ARG GITHUB_HEAD_REF="master"
ARG GITHUB_EVENT_NAME="push"

# Add github
RUN apk update && \
Expand All @@ -12,10 +13,19 @@ RUN apk update && \
git \
make

# Copy repo
COPY ${GO_BUILD_FILES} /go/src/${GO_BUILD_FILES}
WORKDIR /go/src

WORKDIR /go/src/${GO_BUILD_FILES}
# Clone repo
RUN git clone https://github.com/senzing/git-action-jira-issue-creation.git

WORKDIR /go/src/git-action-jira-issue-creation

# Check merge if build is triggered by a pull request
WORKDIR /go/src/git-action-jira-issue-creation
RUN if [[ "${GITHUB_HEAD_REF}" != "master" && "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then \
git checkout ${GITHUB_HEAD_REF}; \
git merge master; \
fi

# Building go app
RUN make build
Expand Down

0 comments on commit 53afce9

Please sign in to comment.