-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (161 loc) · 4.98 KB
/
build.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Build & Deploy
on:
workflow_dispatch:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
jobs:
client-checks:
name: Client Checks
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/client
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Clean Up
run: rm ../../package.json
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-client-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-client-
- name: Install dependencies
run: npm install
- name: Check Formatting
run: npm run prettier
client-docker:
name: Client Docker Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/client
steps:
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
- name: Clean Up
run: rm ../../package.json
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
hicsail/sail-time-tracker-frontend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to Docker Hub
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push Docker Build
uses: docker/build-push-action@v4
with:
context: ./packages/client
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=client
cache-to: type=gha,scope=client,mode=max
server-checks:
name: Server Checks
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/server
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Clean Up
run: rm ../../package.json
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-server-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-server-
- name: Install dependencies
run: |
npm install
npm run prisma:generate
- name: Check Formatting
run: npm run prettier
- name: Check Linting
run: npm run lint
- name: Tests
continue-on-error: true
run: npm run test:cov
server-docker:
name: Server Docker Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/server
steps:
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
- name: Clean Up
run: rm ../../package.json
- name: Login to Docker Hub
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
hicsail/sail-time-tracker-backend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
- name: Build & Push Docker Build
uses: docker/build-push-action@v4
with:
context: ./packages/server
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=server
cache-to: type=gha,mode=max,scope=server
deployment:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
needs: [ client-docker, server-docker ]
steps:
- name: Push to Staging
uses: fjogeleit/http-request-action@v1
with:
method: "POST"
url: ${{ secrets.PORTAINER_WEBHOOK }}
preventFailureOnNoResponse: true
- name: Push to Production
uses: fjogeleit/http-request-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
method: "POST"
url: ${{ secrets.PORTAINER_WEBHOOK_PRODUCTION }}
preventFailureOnNoResponse: true