forked from gabe565/portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (157 loc) Β· 5.04 KB
/
build.yaml
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
name: Build
on:
push:
tags:
- 'v*'
jobs:
backend-lint:
name: Backend Lint
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Lint
uses: golangci/golangci-lint-action@v6
frontend-lint:
name: Frontend Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Node.js for use with actions
uses: actions/setup-node@v4
with:
node-version-file: frontend/.nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm --prefix frontend install --prefer-offline --no-audit
- run: npm --prefix frontend run lint
build-backend:
name: Build Backend Image
runs-on: ubuntu-24.04
outputs:
digest: ${{ steps.docker_build.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta (backend)
id: meta-backend
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/sphincz/sphincz-website-backend
tags: |
type=raw,priority=1000,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and Push Backend
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.prod
pull: true
push: ${{ github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') }}
platforms: linux/amd64
tags: ${{ steps.meta-backend.outputs.tags }}
target: backend
labels: ${{ steps.meta-backend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-frontend:
name: Build Frontend
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: frontend/.nvmrc
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm --prefix=frontend install --prefer-offline --no-audit
- name: Build
env:
VITE_API_ADDRESS: http://localhost:8090
VITE_PLAUSIBLE_HOST: http://localhost:8001
VITE_TURNSTILE_KEY: ${{ secrets.VITE_TURNSTILE_KEY }}
run: npm --prefix=frontend run build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: frontend/dist
build-frontend-image:
name: Build Frontend Image
runs-on: ubuntu-24.04
needs: [build-frontend]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta (frontend)
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/sphincz/sphincz-website-frontend
tags: |
type=raw,priority=1000,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and Push Frontend
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.prod
pull: true
push: ${{ github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/v') }}
platforms: linux/amd64
tags: ${{ steps.meta-frontend.outputs.tags }}
target: frontend
labels: ${{ steps.meta-frontend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
name: Release
runs-on: ubuntu-24.04
needs: [backend-lint, frontend-lint, build-backend, build-frontend, build-frontend-image]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Release
uses: softprops/action-gh-release@v2