Replacing Circle CI with GH actions
- Building and pushing images to our artifactory
This commit is contained in:
parent
b7f741b32d
commit
57c661603c
|
|
@ -1,62 +0,0 @@
|
||||||
shared_configs:
|
|
||||||
simple_job_steps: &simple_job_steps
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: Run tests
|
|
||||||
command: |
|
|
||||||
make deps test
|
|
||||||
|
|
||||||
|
|
||||||
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
|
|
||||||
version: 2.1
|
|
||||||
jobs:
|
|
||||||
build-1-14:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.14
|
|
||||||
steps: *simple_job_steps
|
|
||||||
|
|
||||||
build-1-15:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.15
|
|
||||||
steps: *simple_job_steps
|
|
||||||
|
|
||||||
build-1-16:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- go-mod-v4-{{ checksum "go.sum" }}
|
|
||||||
- run:
|
|
||||||
name: Install Dependencies
|
|
||||||
command: go mod download
|
|
||||||
- save_cache:
|
|
||||||
key: go-mod-v4-{{ checksum "go.sum" }}
|
|
||||||
paths:
|
|
||||||
- "/go/pkg/mod"
|
|
||||||
- run:
|
|
||||||
name: Run tests
|
|
||||||
command: |
|
|
||||||
#mkdir -p /tmp/test-reports
|
|
||||||
#gotestsum --junitfile /tmp/test-reports/unit-tests.xml
|
|
||||||
make ci
|
|
||||||
#- store_test_results:
|
|
||||||
# path: /tmp/test-reports
|
|
||||||
|
|
||||||
build-1-17:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.17
|
|
||||||
steps: *simple_job_steps
|
|
||||||
|
|
||||||
workflows:
|
|
||||||
pr-build-test:
|
|
||||||
jobs:
|
|
||||||
- build-1-14
|
|
||||||
- build-1-15
|
|
||||||
- build-1-16
|
|
||||||
- build-1-17
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
---
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**' # matches every branch
|
||||||
|
tags:
|
||||||
|
- '*' # matches every tag that doesn't contain a '/'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_push_image:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Prepare
|
||||||
|
id: prep
|
||||||
|
run: |
|
||||||
|
DOCKER_IMAGE=xmix-docker-dev/grpcurl
|
||||||
|
VERSION=edge
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
|
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||||
|
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
||||||
|
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
||||||
|
VERSION=pr-${{ github.event.number }}
|
||||||
|
fi
|
||||||
|
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
||||||
|
# TODO: Refine... was creating too many hashes
|
||||||
|
# if [ "${{ github.event_name }}" = "push" ]; then
|
||||||
|
# TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
|
||||||
|
# fi
|
||||||
|
# if we pushed a tag, we also want publish a new latest image
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
||||||
|
fi
|
||||||
|
echo "TAGS to build and push are ${TAGS}"
|
||||||
|
echo ::set-output name=version::${VERSION}
|
||||||
|
echo ::set-output name=tags::${TAGS}
|
||||||
|
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Login to Nuance JFrog Artifactory
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.ARTIFACTORY_URL }}
|
||||||
|
username: ${{ secrets.XMIX_PUBLISH_USERNAME }}
|
||||||
|
password: ${{ secrets.XMIX_PUBLISH_PASSWORD }}
|
||||||
|
-
|
||||||
|
name: Build and push to artifactory
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
build-args: VERSION=${{ steps.prep.outputs.version }}
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: "${{ secrets.ARTIFACTORY_URL }}/${{ steps.prep.outputs.tags }}"
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
||||||
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
||||||
|
org.opencontainers.image.revision=${{ github.sha }}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
FROM golang:1.17.3-alpine as builder
|
FROM golang:1.17.3-alpine as builder
|
||||||
|
ARG ${VERSION:-1.0.0}
|
||||||
MAINTAINER FullStory Engineering
|
MAINTAINER FullStory Engineering
|
||||||
|
|
||||||
# create non-privileged group and user
|
# create non-privileged group and user
|
||||||
|
|
@ -6,14 +7,14 @@ RUN addgroup -S grpcurl && adduser -S grpcurl -G grpcurl
|
||||||
|
|
||||||
WORKDIR /tmp/fullstorydev/grpcurl
|
WORKDIR /tmp/fullstorydev/grpcurl
|
||||||
# copy just the files/sources we need to build grpcurl
|
# copy just the files/sources we need to build grpcurl
|
||||||
COPY VERSION *.go go.* /tmp/fullstorydev/grpcurl/
|
COPY *.go go.* /tmp/fullstorydev/grpcurl/
|
||||||
COPY cmd /tmp/fullstorydev/grpcurl/cmd
|
COPY cmd /tmp/fullstorydev/grpcurl/cmd
|
||||||
# and build a completely static binary (so we can use
|
# and build a completely static binary (so we can use
|
||||||
# scratch as basis for the final image)
|
# scratch as basis for the final image)
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
ENV GO111MODULE=on
|
ENV GO111MODULE=on
|
||||||
RUN go build -o /grpcurl \
|
RUN go build -o /grpcurl \
|
||||||
-ldflags "-w -extldflags \"-static\" -X \"main.version=$(cat VERSION)\"" \
|
-ldflags "-w -extldflags \"-static\" -X \"main.version=${VERSION}\"" \
|
||||||
./cmd/grpcurl
|
./cmd/grpcurl
|
||||||
|
|
||||||
# New FROM so we have a nice'n'tiny image
|
# New FROM so we have a nice'n'tiny image
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue