Skip to content

Commit

Permalink
add github actions (#7)
Browse files Browse the repository at this point in the history
* add github actions

* upload artifacts

* Update Makefile

Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>

Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>
  • Loading branch information
osterman and aknysh committed Jul 1, 2020
1 parent 6b45899 commit fa6c155
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 67 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -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 }}_*
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
18 changes: 6 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion glide.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/cloudposse/slack-notifier

go 1.13

0 comments on commit fa6c155

Please sign in to comment.