This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (110 loc) · 3.78 KB
/
deploy.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
name: Deploy
on:
# allow manual dispatch
workflow_dispatch:
push:
branches:
- master
- staging
concurrency:
group: ${{ github.ref }}-deploy
cancel-in-progress: true
env:
REGISTRY: ghcr.io
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Get timestamp
id: timestamp
run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Set up pnpm
uses: pnpm/[email protected]
with:
version: 7
- name: Cache Maven Deps
uses: actions/cache@v3
with:
path: $GITHUB_WORKSPACE/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache pnpm
uses: actions/cache@v3
with:
path: "/home/runner/.local/share/pnpm/store/v3"
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Build backend
working-directory: backend
run: mvn --batch-mode --errors --fail-at-end --show-version --no-transfer-progress -Dmaven.repo.local=$GITHUB_WORKSPACE/.m2/repository install
- name: Install frontend deps
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Lint frontend
working-directory: frontend
run: pnpm prep && pnpm lint:eslint
- name: Build frontend
working-directory: frontend
run: pnpm build
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker (frontend)
id: frontend-meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/frontend
tags: |
type=sha,enable=true,format=short,prefix=${{ env.BRANCH_NAME }}-,suffix=-${{ steps.timestamp.outputs.timestamp }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push frontend Dockerfile
uses: docker/build-push-action@v3
with:
context: .
file: chart/dockerfiles/frontend/Dockerfile
tags: ${{ steps.frontend-meta.outputs.tags }}
labels: ${{ steps.frontend-meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract metadata (tags, labels) for Docker (backend)
id: backend-meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/backend
tags: |
type=sha,enable=true,format=short,prefix=${{ env.BRANCH_NAME }}-,suffix=-${{ steps.timestamp.outputs.timestamp }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push backend Dockerfile
uses: docker/build-push-action@v3
with:
context: .
file: chart/dockerfiles/backend/Dockerfile
tags: ${{ steps.backend-meta.outputs.tags }}
labels: ${{ steps.backend-meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max