diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..4482f84 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,25 @@ +name: "docker" +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] + release: + types: + - created +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: "Checkout source code at current commit" + uses: actions/checkout@v2 + - name: "Build and push docker image to DockerHub" + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + repository: ${{ github.repository }} + registry: registry-1.docker.io + tag_with_ref: true + tag_with_sha: true diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..4fd83d2 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,53 @@ +name: 'go' + +on: + release: + types: [published] + + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Checkout the repo + - name: 'Checkout' + uses: actions/checkout@v2 + # Build Go binaries + - name: 'Build Go binaries' + uses: cloudposse/actions/go/build@0.15.0 + env: + GO111MODULE: on + # Architectures to build for + GOX_OSARCH: >- + windows/386 + windows/amd64 + freebsd/arm + netbsd/386 + netbsd/amd64 + netbsd/arm + linux/s390x + linux/arm + darwin/386 + darwin/amd64 + linux/386 + linux/amd64 + freebsd/amd64 + freebsd/386 + openbsd/386 + openbsd/amd64 + OUTPUT_PATH: ${{ github.workspace }}/release/${{ github.event.repository.name }}_ + # Upload artifacts for this build + - name: 'Upload artifacts' + uses: actions/upload-artifact@v2 + with: + name: ${{ github.event.repository.name }} + path: ${{ github.workspace }}/release/* + # Attach Go binaries to GitHub Release + - name: 'Attach artifacts to GitHub Release' + if: ${{ github.event_name == 'release' }} + uses: cloudposse/actions/github/release-assets@0.15.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + INPUT_PATH: ${{ github.workspace }}/release/${{ github.event.repository.name }}_* diff --git a/.gitignore b/.gitignore index 72bcb00..7f02f0c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,4 @@ slack-notifier # Output of the go coverage tool, specifically when used with LiteIDE *.out -# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 -.glide/ +build-harness/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9aaaa53..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -sudo: required - -language: go -go: - - 1.9.x -addons: - apt: - packages: - - git - - make - - curl - -env: - - DOCKER_IMAGE_NAME=cloudposse/slack-notifier - -services: -- docker - -install: -- make init -- make travis/docker-login -- make go/deps-build -- make go/deps-dev -- make go-get - -script: -- make go/deps -- make go/test -- make go/lint -- make go/build-all -- ls -l release/ -- make docker/build - -after_success: -- make travis/docker-tag-and-push - -deploy: - - provider: releases - api_key: "$GITHUB_API_KEY" - file_glob: true - file: "release/*" - skip_cleanup: true - on: - tags: true diff --git a/Dockerfile b/Dockerfile index 41e40ad..9961f51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ -FROM golang:1.9.3 as builder -RUN mkdir -p /go/src/github.com/cloudposse/slack-notifier -WORKDIR /go/src/github.com/cloudposse/slack-notifier -COPY . . -RUN go get && CGO_ENABLED=0 go build -v -o "./dist/bin/slack-notifier" *.go +FROM golang:1.13.3-buster as builder +ENV GO111MODULE=on +ENV CGO_ENABLED=0 +WORKDIR /usr/src/ +COPY . /usr/src +RUN go build -v -o "bin/slack-notifier" *.go - -FROM alpine:3.6 +FROM alpine:3.12 RUN apk add --no-cache ca-certificates -COPY --from=builder /go/src/github.com/cloudposse/slack-notifier/dist/bin/slack-notifier /usr/bin/slack-notifier +COPY --from=builder /usr/src/bin/* /usr/bin/ ENV PATH $PATH:/usr/bin ENTRYPOINT ["slack-notifier"] diff --git a/Makefile b/Makefile index 12c56fe..ea8a0f4 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,9 @@ SHELL = /bin/bash -PATH:=$(PATH):$(GOPATH)/bin +export DOCKER_ORG ?= cloudposse +export DOCKER_IMAGE ?= $(DOCKER_ORG)/slack-notifier +export DOCKER_TAG ?= latest +export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG) +export DOCKER_BUILD_FLAGS = -include $(shell curl --silent -o .build-harness "https://raw.githubusercontent.com/cloudposse/build-harness/master/templates/Makefile.build-harness"; echo .build-harness) - - -.PHONY : go-get -go-get: - go get - - -.PHONY : go-build -go-build: go-get - CGO_ENABLED=0 go build -v -o "./dist/bin/slack-notifier" *.go +-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 47beb3f..0000000 --- a/glide.yaml +++ /dev/null @@ -1 +0,0 @@ -package: github.com/cloudposse/slack-notifier diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a061b15 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/cloudposse/slack-notifier + +go 1.13