-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (53 loc) · 1.77 KB
/
build-project.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Build Project
on: push
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
DOCKER_USERNAME: joonatanaatos
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
strategy:
matrix:
component:
- { dir: 'backend', image: 'joonatanaatos/kuka-soittaa-backend' }
- {
dir: 'admin-panel',
image: 'joonatanaatos/kuka-soittaa-admin-panel',
}
- { dir: 'app' }
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: Extract branch name
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
if: matrix.component.image
- name: Push Docker image
uses: docker/build-push-action@v5
with:
push: true
context: ${{ matrix.component.dir }}
tags: ${{ matrix.component.image }}:${{ env.BRANCH_NAME }}
if: matrix.component.image
- 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