-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (86 loc) · 3.37 KB
/
ci.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: CI
on:
pull_request:
types: [opened, synchronize]
jobs:
build:
name: Build
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: glemenneo/cs3219-ay2425s1-project-g31-user-service
dockerfile: ./backend/user-service/Dockerfile
- image: glemenneo/cs3219-ay2425s1-project-g31-question-service
dockerfile: ./backend/question-service/Dockerfile
- image: glemenneo/cs3219-ay2425s1-project-g31-matching-service
dockerfile: ./backend/matching-service/Dockerfile
- image: glemenneo/cs3219-ay2425s1-project-g31-collaboration-service
dockerfile: ./backend/collaboration-service/Dockerfile
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: false # Do not push to Docker Hub, only cache the image for later use in CD
tags: ${{ matrix.image }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
test:
name: Test
timeout-minutes: 15
runs-on: ubuntu-latest
# To use Remote Caching, uncomment the next lines and follow the steps below.
# env:
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# TURBO_REMOTE_ONLY: true
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache turbo artifacts
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build # Required to build the internal
- name: Test
run: npm run test