Skip to content

Commit

Permalink
Add publish step to github actions
Browse files Browse the repository at this point in the history
Signed-off-by: Alistair Hey <[email protected]>
  • Loading branch information
Waterdrips committed Dec 5, 2020
1 parent 5ec55c1 commit 068f12a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 9 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 ./

Expand Down
6 changes: 3 additions & 3 deletions gateway/scaling/function_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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})
Expand All @@ -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})
Expand Down

0 comments on commit 068f12a

Please sign in to comment.