Add publish step to github actions

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
This commit is contained in:
Alistair Hey 2020-11-22 12:46:51 +00:00 committed by Alex Ellis
parent e3b18e6324
commit ca3d53c0a5
5 changed files with 98 additions and 10 deletions

View File

@ -8,8 +8,6 @@ on:
branches:
- '*'
# pull buildargs out of container (stop putting git in)
# can then go back to matrix build of containers
jobs:
# Run the CI tests
@ -88,7 +86,7 @@ jobs:
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:latest
build-auth-containers:
build-auth-plugins:
runs-on: ubuntu-latest
strategy:
matrix:

88
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,88 @@
name: piblish
on:
push:
tags:
- '*'
jobs:
publish-gateway:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13.x]
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: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Build ${{ matrix.svc }}
uses: docker/build-push-action@v2
with:
context: ./gateway
file: ./gateway/Dockerfile
outputs: "type=registry,push=true"
platforms: linux/amd64,linux/arm/v7,linux/arm64
build-args: |
VERSION=${{ steps.get_tag.outputs.TAG }}
GIT_COMMIT=${{ github.sha }}
GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }}
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:latest
publish-auth-plugins:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.13.x]
svc: [
basic-auth
]
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: Get TAG
id: get_tag
run: echo ::set-output name=TAG::latest-dev
- name: Login to Docker Registry
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
- name: Get Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Build ${{ matrix.svc }}
uses: docker/build-push-action@v2
with:
context: ./auth/${{ matrix.svc }}
file: ./auth/${{ matrix.svc }}/Dockerfile
outputs: "type=registry,push=true"
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ matrix.svc }}:latest

View File

@ -1,4 +1,4 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} teamserverless/license-check:0.3.6 as license-check
FROM --platform=${BUILDPLATFORM:-linux/amd64} teamserverless/license-check:0.3.9 as license-check
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build

View File

@ -1,4 +1,4 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} teamserverless/license-check:0.3.6 as license-check
FROM --platform=${BUILDPLATFORM:-linux/amd64} teamserverless/license-check:0.3.9 as license-check
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build
@ -68,8 +68,10 @@ ENV https_proxy ""
COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway .
COPY assets assets
RUN sed -ie s/x86_64/${GOARCH}/g assets/script/funcstore.js && \
rm assets/script/funcstore.jse
ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] ; then sed -ie s/x86_64/armhf/g assets/script/funcstore.js ; elif [ "$TARGETPLATFORM" = "linux/arm64" ] ; then sed -ie s/x86_64/arm64/g assets/script/funcstore.js; fi
RUN chown -R app:app ./

View File

@ -81,7 +81,7 @@ func Test_CacheFunctionExists(t *testing.T) {
cache := FunctionCache{
Cache: make(map[string]*FunctionMeta),
Expiry: time.Millisecond * 10,
Expiry: time.Millisecond * 100,
}
cache.Set(fnName, namespace, ServiceQueryResponse{AvailableReplicas: 1})
@ -102,7 +102,7 @@ func Test_CacheFunctionExistsWithNamespace(t *testing.T) {
cache := FunctionCache{
Cache: make(map[string]*FunctionMeta),
Expiry: time.Millisecond * 10,
Expiry: time.Millisecond * 100,
}
cache.Set(fnName, namespace, ServiceQueryResponse{AvailableReplicas: 1})
@ -123,7 +123,7 @@ func Test_CacheFunctionNotExist(t *testing.T) {
cache := FunctionCache{
Cache: make(map[string]*FunctionMeta),
Expiry: time.Millisecond * 10,
Expiry: time.Millisecond * 100,
}
cache.Set(fnName, namespace, ServiceQueryResponse{AvailableReplicas: 1})