parent
d424577ce5
commit
27796c0e04
|
@ -0,0 +1,39 @@
|
||||||
|
name: Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
env:
|
||||||
|
GOPATH: ${{ github.workspace }}
|
||||||
|
GOCACHE: /tmp/gocache
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up Go 1.13
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.13
|
||||||
|
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: ./src/github.com/${{ github.repository }}
|
||||||
|
|
||||||
|
- name: Setup build environment
|
||||||
|
run: |
|
||||||
|
mkdir -p $GOCACHE
|
||||||
|
cd ./src/github.com/${{ github.repository }}
|
||||||
|
go version
|
||||||
|
|
||||||
|
- name: Test and build package
|
||||||
|
run: |
|
||||||
|
cd ./src/github.com/${{ github.repository }}
|
||||||
|
make test
|
||||||
|
make build
|
|
@ -0,0 +1,23 @@
|
||||||
|
name: Docker image
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Build and push Docker image
|
||||||
|
env:
|
||||||
|
IMAGE_REPO: rchakode/kube-mx-gateway
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
run: |
|
||||||
|
make build-ci
|
||||||
|
export GIT_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||||
|
export IMAGE_TAG=$(echo $GIT_TAG | sed 's/v//')
|
||||||
|
docker build . --file Dockerfile --tag ${IMAGE_REPO}:${IMAGE_TAG}
|
||||||
|
docker tag ${IMAGE_REPO}:${IMAGE_TAG} ${IMAGE_REPO}:latest
|
||||||
|
echo "$REGISTRY_PASSWORD" | docker login -u $REGISTRY_USERNAME --password-stdin
|
||||||
|
docker push ${IMAGE_REPO}
|
8
Makefile
8
Makefile
|
@ -1,5 +1,5 @@
|
||||||
PACKAGE_NAME=./bin/hugo-mx-gateway
|
PACKAGE_NAME=./bin/hugo-mx-gateway
|
||||||
DOCKER_IMAGE=rchakode/hugo-mx-gateway
|
DOCKER_IMAGE_REPO=rchakode/hugo-mx-gateway
|
||||||
ARCH=$$(uname -m)
|
ARCH=$$(uname -m)
|
||||||
GOCMD=GO111MODULE=on go
|
GOCMD=GO111MODULE=on go
|
||||||
GOBUILD=$(GOCMD) build
|
GOBUILD=$(GOCMD) build
|
||||||
|
@ -14,7 +14,7 @@ all: test build
|
||||||
build:
|
build:
|
||||||
$(GOBUILD) -o $(PACKAGE_NAME) -v
|
$(GOBUILD) -o $(PACKAGE_NAME) -v
|
||||||
|
|
||||||
build-docker:
|
build-ci:
|
||||||
docker run --rm -it \
|
docker run --rm -it \
|
||||||
-e GO111MODULE=on \
|
-e GO111MODULE=on \
|
||||||
-e CGO_ENABLED=0 \
|
-e CGO_ENABLED=0 \
|
||||||
|
@ -24,7 +24,9 @@ build-docker:
|
||||||
-w /app \
|
-w /app \
|
||||||
$(GOIMAGE) \
|
$(GOIMAGE) \
|
||||||
go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o "$(PACKAGE_NAME)" -v
|
go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o "$(PACKAGE_NAME)" -v
|
||||||
docker build -t $(DOCKER_IMAGE):$$(date +%s) .
|
|
||||||
|
container: build-ci
|
||||||
|
docker build -t $(DOCKER_IMAGE_REPO):$$(date +%s) .
|
||||||
|
|
||||||
build-compress: build
|
build-compress: build
|
||||||
$(UPX) $(PACKAGE_NAME)
|
$(UPX) $(PACKAGE_NAME)
|
||||||
|
|
Loading…
Reference in New Issue