Skip to content

Commit fa6c155

Browse files
ostermanaknysh
andauthored
add github actions (#7)
* add github actions * upload artifacts * Update Makefile Co-authored-by: Andriy Knysh <[email protected]> Co-authored-by: Andriy Knysh <[email protected]>
1 parent 6b45899 commit fa6c155

File tree

8 files changed

+96
-67
lines changed

8 files changed

+96
-67
lines changed

.github/workflows/docker.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "docker"
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
release:
9+
types:
10+
- created
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: "Checkout source code at current commit"
16+
uses: actions/checkout@v2
17+
- name: "Build and push docker image to DockerHub"
18+
uses: docker/build-push-action@v1
19+
with:
20+
username: ${{ secrets.DOCKERHUB_USERNAME }}
21+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
22+
repository: ${{ github.repository }}
23+
registry: registry-1.docker.io
24+
tag_with_ref: true
25+
tag_with_sha: true

.github/workflows/go.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'go'
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
# Checkout the repo
15+
- name: 'Checkout'
16+
uses: actions/checkout@v2
17+
# Build Go binaries
18+
- name: 'Build Go binaries'
19+
uses: cloudposse/actions/go/[email protected]
20+
env:
21+
GO111MODULE: on
22+
# Architectures to build for
23+
GOX_OSARCH: >-
24+
windows/386
25+
windows/amd64
26+
freebsd/arm
27+
netbsd/386
28+
netbsd/amd64
29+
netbsd/arm
30+
linux/s390x
31+
linux/arm
32+
darwin/386
33+
darwin/amd64
34+
linux/386
35+
linux/amd64
36+
freebsd/amd64
37+
freebsd/386
38+
openbsd/386
39+
openbsd/amd64
40+
OUTPUT_PATH: ${{ github.workspace }}/release/${{ github.event.repository.name }}_
41+
# Upload artifacts for this build
42+
- name: 'Upload artifacts'
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: ${{ github.event.repository.name }}
46+
path: ${{ github.workspace }}/release/*
47+
# Attach Go binaries to GitHub Release
48+
- name: 'Attach artifacts to GitHub Release'
49+
if: ${{ github.event_name == 'release' }}
50+
uses: cloudposse/actions/github/[email protected]
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
INPUT_PATH: ${{ github.workspace }}/release/${{ github.event.repository.name }}_*

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ slack-notifier
1616
# Output of the go coverage tool, specifically when used with LiteIDE
1717
*.out
1818

19-
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
20-
.glide/
19+
build-harness/

.travis.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM golang:1.9.3 as builder
2-
RUN mkdir -p /go/src/github.com/cloudposse/slack-notifier
3-
WORKDIR /go/src/github.com/cloudposse/slack-notifier
4-
COPY . .
5-
RUN go get && CGO_ENABLED=0 go build -v -o "./dist/bin/slack-notifier" *.go
1+
FROM golang:1.13.3-buster as builder
2+
ENV GO111MODULE=on
3+
ENV CGO_ENABLED=0
4+
WORKDIR /usr/src/
5+
COPY . /usr/src
6+
RUN go build -v -o "bin/slack-notifier" *.go
67

7-
8-
FROM alpine:3.6
8+
FROM alpine:3.12
99
RUN apk add --no-cache ca-certificates
10-
COPY --from=builder /go/src/github.com/cloudposse/slack-notifier/dist/bin/slack-notifier /usr/bin/slack-notifier
10+
COPY --from=builder /usr/src/bin/* /usr/bin/
1111
ENV PATH $PATH:/usr/bin
1212
ENTRYPOINT ["slack-notifier"]

Makefile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
SHELL = /bin/bash
22

3-
PATH:=$(PATH):$(GOPATH)/bin
3+
export DOCKER_ORG ?= cloudposse
4+
export DOCKER_IMAGE ?= $(DOCKER_ORG)/slack-notifier
5+
export DOCKER_TAG ?= latest
6+
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
7+
export DOCKER_BUILD_FLAGS =
48

5-
include $(shell curl --silent -o .build-harness "https://raw.githubusercontent.com/cloudposse/build-harness/master/templates/Makefile.build-harness"; echo .build-harness)
6-
7-
8-
.PHONY : go-get
9-
go-get:
10-
go get
11-
12-
13-
.PHONY : go-build
14-
go-build: go-get
15-
CGO_ENABLED=0 go build -v -o "./dist/bin/slack-notifier" *.go
9+
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)

glide.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/cloudposse/slack-notifier
2+
3+
go 1.13

0 commit comments

Comments
 (0)