-
-
Notifications
You must be signed in to change notification settings - Fork 105
184 lines (170 loc) · 7.06 KB
/
deploy.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
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Deploy
on:
push:
branches: ['main', 'dev', 'feature/**']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
version:
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.version.outputs.package_version }}
steps:
# SETUP
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'yarn'
- if: ${{ github.ref_name == 'main' }}
run: yarn --immutable --immutable-cache
- if: ${{ github.ref_name == 'main' }}
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "package_version=$(yarn semantic-release -d | sed -n 's/.*next release version is \([0-9]\+\.[0-9]\+\.[0-9]\+\)/\1/p')" >> "$GITHUB_OUTPUT"
- if: ${{ github.ref_name == 'main' }}
run: |
[ ! -z "${package_version}" ] || exit 1
deploy:
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v2
with:
username: mauricenino
password: ${{ secrets.DOCKERHUB_TOKEN }}
# fix oom issues (https://github.com/orgs/community/discussions/26351)
- run: |
df -h
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
df -h
- uses: docker/metadata-action@v4
id: meta
with:
images: |
ghcr.io/mauricenino/dashdot
mauricenino/dashdot
labels: |
org.opencontainers.image.title="dash."
org.opencontainers.image.description="dash. - a modern server dashboard"
org.opencontainers.image.authors="MauriceNino <[email protected]>"
org.opencontainers.image.url=https://github.com/MauriceNino/dashdot
org.opencontainers.image.source=https://github.com/MauriceNino/dashdot
org.opencontainers.image.licenses=MIT
tags: |
type=semver,pattern={{version}},value=${{ format('v{0}', needs.version.outputs.package_version) }},enable=${{ github.ref_name == 'main' }}
type=semver,pattern={{major}}.{{minor}},value=${{ format('v{0}', needs.version.outputs.package_version) }},enable=${{ github.ref_name == 'main' }}
type=semver,pattern={{major}},value=${{ format('v{0}', needs.version.outputs.package_version) }},enable=${{ github.ref_name == 'main' }}
type=ref,event=branch,enable=${{ github.ref_name != 'main' }}
- uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64/v8
target: prod
push: true
build-args: |
VERSION=${{ github.ref_name == 'main' && needs.version.outputs.package_version || format('0.0.0-{0}', github.ref_name) }}
BUILDHASH=${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy_nvidia:
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v2
with:
username: mauricenino
password: ${{ secrets.DOCKERHUB_TOKEN }}
# fix oom issues (https://github.com/orgs/community/discussions/26351)
- run: |
df -h
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
df -h
- uses: docker/metadata-action@v4
id: meta_nvidia
with:
flavor: |
latest=false
images: |
ghcr.io/mauricenino/dashdot
mauricenino/dashdot
labels: |
org.opencontainers.image.title="dash."
org.opencontainers.image.description="dash. - a modern server dashboard"
org.opencontainers.image.authors="MauriceNino <[email protected]>"
org.opencontainers.image.url=https://github.com/MauriceNino/dashdot
org.opencontainers.image.source=https://github.com/MauriceNino/dashdot
org.opencontainers.image.licenses=MIT
tags: |
type=semver,pattern={{version}},value=${{ format('v{0}', needs.version.outputs.package_version) }},enable=${{ github.ref_name == 'main' }},prefix=nvidia-
type=semver,pattern={{major}}.{{minor}},value=${{ format('v{0}', needs.version.outputs.package_version) }},enable=${{ github.ref_name == 'main' }},prefix=nvidia-
type=semver,pattern={{major}},value=${{ format('v{0}', needs.version.outputs.package_version) }},enable=${{ github.ref_name == 'main' }},prefix=nvidia-
type=ref,event=branch,enable=${{ github.ref_name != 'main' }},prefix=nvidia-
type=raw,value=nvidia,enable=${{ github.ref_name == 'main' }}
- uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.nvidia
platforms: linux/amd64,linux/arm64/v8
target: prod
push: true
build-args: |
VERSION=${{ github.ref_name == 'main' && needs.version.outputs.package_version || format('0.0.0-{0}', github.ref_name) }}
BUILDHASH=${{ github.sha }}
labels: ${{ steps.meta_nvidia.outputs.labels }}
tags: ${{ steps.meta_nvidia.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Update deployment on rex
release:
runs-on: ubuntu-latest
needs: [deploy, deploy_nvidia]
steps:
- if: ${{ github.ref_name == 'main' }}
env:
GIT_USER: github-actions
GIT_AUTHOR_NAME: github-actions
GIT_COMMITTER_NAME: github-actions
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_PASS: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn semantic-release
yarn nx build docs
yarn nx deploy docs
# Update deployment on rex
rex:
runs-on: ubuntu-latest
needs: deploy
steps:
- if: ${{ github.ref_name == 'main' }}
run: curl --get --data-urlencode "service=dashdot" --data-urlencode "image=mauricenino/dashdot:latest" --data-urlencode "secret=${{ secrets.REX_TOKEN }}" https://rex.mauz.dev/deploy
- if: ${{ github.ref_name == 'dev' }}
run: curl --get --data-urlencode "service=dashdot" --data-urlencode "image=mauricenino/dashdot:dev" --data-urlencode "secret=${{ secrets.REX_TOKEN }}" https://rex.mauz.dev/deploy