71 lines
1.8 KiB
YAML
71 lines
1.8 KiB
YAML
name: Build and test
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
test:
|
|
name: Run linter and tests
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16'
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
- name: Run linter
|
|
run: npm run lint
|
|
# # TODO: fix tests... currently broken.
|
|
# - name: Run tests
|
|
# run: |
|
|
# cp .env.sample .env
|
|
# npm test
|
|
|
|
build:
|
|
name: Build app
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16'
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
docker:
|
|
name: Build Docker image
|
|
runs-on: ubuntu-20.04
|
|
needs:
|
|
- test
|
|
- build
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v3
|
|
with:
|
|
images: ghcr.io/RetroPilot/retropilot-server
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
type=sha
|
|
- name: Login to GHCR
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|