Skip to content

Add CI pipeline

Add CI pipeline #20

Workflow file for this run

name: Build Project
on: [push, pull_request]
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
component:
- { dir: 'backend', image: '$DOCKER_USERNAME/kuka-soittaa-backend' }
- {
dir: 'admin-panel',
image: '$DOCKER_USERNAME/kuka-soittaa-admin-panel',
}
- { dir: 'app' }
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
PUSH_DOCKER: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Install dependencies for ${{ matrix.component.dir }}
run: |
cd ${{ matrix.component.dir }}
yarn install --frozen-lockfile --non-interactive
- name: Lint ${{ matrix.component.dir }}
run: |
cd ${{ matrix.component.dir }}
yarn lint
- name: Build ${{ matrix.component.dir }}
run: |
cd ${{ matrix.component.dir }}
yarn build
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
if: matrix.component.image && env.PUSH_DOCKER
- name: Push Docker image
uses: docker/build-push-action@v5
with:
push: true
context: ${{ matrix.component.dir }}
tags: ${{ matrix.component.image }}:${{ GITHUB_HEAD_REF##*/ }}

Check failure on line 46 in .github/workflows/build-project.yml

View workflow run for this annotation

GitHub Actions / Build Project

Invalid workflow file

The workflow is not valid. .github/workflows/build-project.yml (Line: 46, Col: 17): Unexpected symbol: 'GITHUB_HEAD_REF##*/'. Located at position 1 within expression: GITHUB_HEAD_REF##*/
if: matrix.component.image && env.PUSH_DOCKER
- name: Push Docker image with latest tag
uses: docker/build-push-action@v5
with:
push: true
context: ${{ matrix.component.dir }}
tags: ${{ matrix.component.image }}:latest
if: github.ref == 'refs/heads/main' && matrix.component.image && env.PUSH_DOCKER