Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to GitHub Actions #173

Merged
merged 3 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ci

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
build:
name: Build-Test
strategy:
matrix:
go-version: [1.15.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Build
run: make build
- name: Test
run: make test
65 changes: 65 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: publish

on:
push:
tags:
- '*'

jobs:

build-test:
name: Build-Test
strategy:
matrix:
go-version: [1.15.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: build
run: make build
- name: Test
run: make test

publish-derek:
runs-on: ubuntu-latest
needs: build-test
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 Repo Owner
id: get_repo_owner
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Login to GHCR Registry
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/derek:${{ steps.get_tag.outputs.TAG }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this now, but if github.repository_owner gives the same value as steps.get_repo_owner.outputs.repo_owner, then we could probably remove that step in the future. I think github.repository_owner must be new, because we didn't find it when looking before? cc @utsavanand2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought that, but i saw an existing example in another openfaas repo that I followed, but I think we can update all to use the envs the github provide, including the tag

I can open a follow up or if you would like

ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/derek:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/derek:latest
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.