-
Notifications
You must be signed in to change notification settings - Fork 1
201 lines (193 loc) · 6.61 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: build
on: [push, pull_request]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
basic-checks:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# See https://github.com/Automattic/node-canvas/issues/599#issuecomment-1336370909
- run: sudo apt-get install -y libsdl-pango-dev libgif-dev
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- run: npm ci
- run: npm run check-packages
lint:
needs: basic-checks
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- run: sudo apt-get install -y libsdl-pango-dev libgif-dev
- uses: actions/checkout@v4
- name: Cache build
id: cache-build
uses: actions/cache@v4
with:
path: node_modules/.cache/nx
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}-build
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- run: npm ci
- run: npm run lint
build-app:
needs: basic-checks
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
workspace: [
common,
client,
server,
portal
]
steps:
- run: sudo apt-get install -y libsdl-pango-dev libgif-dev
- uses: actions/checkout@v4
- name: Cache build
id: cache-build
uses: actions/cache@v4
with:
path: node_modules/.cache/nx
key: ${{ runner.os }}-nx-${{ hashFiles('package-lock.json') }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- run: npm ci
- run: npx lerna run build --scope=@fumix/fu-blog-${{ matrix.workspace }}
- run: echo "This file is placed at the project root, so Github preserves the artifact paths (see https://github.com/actions/upload-artifact/issues/206)" > root.txt
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.workspace }}
path: | # Important to use `|` to preserve the path (see https://github.com/actions/upload-artifact/issues/55#issuecomment-633825395)
${{ matrix.workspace }}/dist/**
root-${{ matrix.workspace }}.txt
if-no-files-found: error
test:
needs: build-app
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- run: sudo apt-get install -y libsdl-pango-dev libgif-dev
- uses: actions/checkout@v4
- name: Cache build
id: cache-build
uses: actions/cache@v4
with:
path: node_modules/.cache/nx
key: ${{ runner.os }}-nx-${{ hashFiles('package-lock.json') }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- run: npm ci
- run: npm run test
publish:
if: (contains('
refs/heads/main
refs/heads/develop
', github.ref) || startsWith(github.ref, 'refs/tags/v')) && github.repository == 'fumiX/fuBlog'
needs: [test, lint, publish-db-image]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- run: sudo apt-get install -y libsdl-pango-dev libgif-dev
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
- run: |
cp -r server/dist/* docker/app/
cp -rT server/test-data/ docker/app/test-data/
cp -rT client/dist/ docker/app/public/
cp server/package.json docker/app/
mkdir -p "docker/app/node_modules/@fumix/"
cp -rT common/ "docker/app/node_modules/@fumix/fu-blog-common"
cd docker/app/
npm install
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}-app
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: docker/app
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish-db-image:
if: (contains('
refs/heads/main
refs/heads/develop
', github.ref) || startsWith(github.ref, 'refs/tags/v')) && github.repository == 'fumiX/fuBlog'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
language: [
de_DE,
en_GB,
en_US
]
steps:
- uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}-postgres
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/docker/postgres
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}/docker/postgres/README.md
org.opencontainers.image.description=PostgreSQL image for use with the fu-blog, customized with locale ${{ matrix.language }} (for postgres search)
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=ref,event=branch
flavor: |
latest=auto
suffix=-${{ matrix.language }},onlatest=true
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
build-args: |
language=${{ matrix.language }}
context: docker/postgres
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}