Skip to content

Commit

Permalink
Migrate builds to Github Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Utsav Anand <[email protected]>
  • Loading branch information
utsavanand2 committed Dec 11, 2020
1 parent 8e9eefd commit d50ee3d
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 37 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: build

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
build:
runs-on: ubuntu-20.04
steps:
-
uses: actions/checkout@master
with:
fetch-depth: 1
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build x86_64 container image into library
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: true
push: false
platforms: linux/amd64
build-args: |
VERSION=latest-dev
GIT_COMMIT=${{ github.sha }}
tags: |
ghcr.io/openfaas/queue-worker:${{ github.sha }}
-
name: Build multi-arch container images (for validation only)
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: false
push: false
platforms: linux/amd64,linux/arm/v7,linux/arm64
build-args: |
VERSION=latest-dev
GIT_COMMIT=${{ github.sha }}
tags: |
ghcr.io/openfaas/queue-worker:${{ github.sha }}
55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: publish

on:
push:
tags:
- "*"

jobs:
publish:
runs-on: ubuntu-20.04
steps:
-
uses: actions/checkout@master
with:
fetch-depth: 1
-
name: Get tags
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
-
name: Set Username/Repo and ImagePrefix as ENV vars
run: |
echo "USER_REPO"=$(echo "$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV && \
echo "IMAGE_PREFIX"=$(echo "ghcr.io/${{ github.repository_owner }}/queue-worker" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV
-
name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and push multi-arch containers images
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: false
push: true
platforms: linux/amd64,linux/arm/v7,linux/arm64
labels: |
org.opencontainers.image.source=https://github.com/${{ env.USER_REPO }}
build-args: |
VERSION=${{ steps.get_tag.outputs.TAG }}
GIT_COMMIT=${{ github.sha }}
tags: |
${{ env.IMAGE_PREFIX }}:${{ github.sha }}
${{ env.IMAGE_PREFIX }}:${{ steps.get_tag.outputs.TAG }}
${{ env.IMAGE_PREFIX }}:latest
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
FROM golang:1.13-alpine as golang
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13-alpine as golang

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ARG GIT_COMMIT
ARG VERSION

ENV CGO_ENABLED=0
ENV GO111MODULE=off

Expand All @@ -15,13 +24,9 @@ COPY readconfig_test.go .
COPY auth.go .
COPY .git .

ARG go_opts

RUN apk add --no-cache git

RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& env $go_opts CGO_ENABLED=0 go build \
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
--ldflags "-s -w \
-X github.com/openfaas/nats-queue-worker/version.GitCommit=${GIT_COMMIT}\
-X github.com/openfaas/nats-queue-worker/version.Version=${VERSION}" \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## queue-worker for NATS Streaming

[![Go Report Card](https://goreportcard.com/badge/github.com/openfaas/nats-queue-worker)](https://goreportcard.com/badge/github.com/openfaas/nats-queue-worker)
[![Build Status](https://travis-ci.com/openfaas/nats-queue-worker.svg?branch=master)](https://travis-ci.com/openfaas/nats-queue-worker)
[![Build Status](https://github.com/openfaas/nats-queue-worker/workflows/build/badge.svg?branch=master)](https://github.com/openfaas/nats-queue-worker/actions)

[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/openfaas/nats-queue-worker?tab=overview)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand All @@ -10,7 +10,7 @@

The queue-worker processes asynchronous function invocation requests, you can read more about this in the [async documentation](https://docs.openfaas.com/reference/async/)

Docker Hub image: [openfaas/queue-worker](https://hub.docker.com/r/openfaas/queue-worker/)
Github Container Registry image: [openfaas/queue-worker](https://github.com/orgs/openfaas/packages/container/package/queue-worker)

License: MIT

Expand Down

0 comments on commit d50ee3d

Please sign in to comment.