v3/.github/workflows/build.yml

100 lines
3.1 KiB
YAML

name: Roleypoly CI
on: push
jobs:
go_test:
runs-on: ubuntu-latest
name: Go CI
steps:
- uses: actions/checkout@master
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v2
with:
go-version: '^1.15.5'
- run: go vet ./...
- run: go test ./...
node_test:
runs-on: ubuntu-latest
name: Node CI
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test
docker_build:
name: Docker Build & Publish
runs-on: ubuntu-latest
needs:
- go_test
- node_test
strategy:
matrix:
dockerfile:
- ui
- bot
steps:
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: docker.pkg.github.com/roleypoly/roleypoly/${{matrix.dockerfile}}
tag-sha: true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./hack/dockerfiles/${{matrix.dockerfile}}.Dockerfile
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ steps.docker_meta.outputs.tags }}