forked from porla/porla
-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (149 loc) · 5.35 KB
/
build-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
name: Build and deploy
on:
pull_request:
push:
branches:
- main
tags:
- 'v*.*.*'
jobs:
calc-version:
name: Run GitVersion
runs-on: ubuntu-latest
outputs:
semVer: ${{ steps.gitversion.outputs.fullSemVer }}
shortSha: ${{ steps.gitversion.outputs.shortSha }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'
- name: Calculate version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.10.2
with:
useConfigFile: true
build-web:
name: Build web UI
needs: [calc-version]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Install Node.js dependencies
run: npm ci
working-directory: ./html
- name: Build web UI
run: npm run build
working-directory: ./html
- name: Package web UI
run: pushd html/dist && zip -9 -r ../webui.zip * && popd && ls -la
- name: Upload web UI to artifacts
uses: actions/upload-artifact@v3
with:
name: webui.zip
path: html/webui.zip
build-app:
strategy:
matrix:
platform: [linux-amd64, linux-arm64]
include:
- platform: linux-amd64
runner: buildjet-4vcpu-ubuntu-2204
- platform: linux-arm64
runner: buildjet-8vcpu-ubuntu-2204-arm
name: Build Porla (${{ matrix.platform }})
needs: [build-web, calc-version]
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Download web UI artifact
uses: actions/download-artifact@v3
with:
name: webui.zip
path: html/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v4
with:
build-args: GITVERSION_SEMVER=${{ needs.calc-version.outputs.semVer }}
context: .
load: true
tags: ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-${{ matrix.platform }}
- name: Copy Porla binary from image
run: |
docker create --name tmp ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-${{ matrix.platform }}
docker cp tmp:/usr/bin/porla /tmp/porla-${{ matrix.platform }}
docker rm -f tmp
- name: Save Docker container
run: |
docker save -o /tmp/porla-${{ matrix.platform }}-docker.tar ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-${{ matrix.platform }}
- name: Upload Docker container to artifacts
uses: actions/upload-artifact@v3
with:
name: porla-${{ matrix.platform }}-docker.tar
path: /tmp/porla-${{ matrix.platform }}-docker.tar
- name: Upload Porla binary to artifacts
uses: actions/upload-artifact@v3
with:
name: porla-${{ matrix.platform }}
path: /tmp/porla-${{ matrix.platform }}
push-docker-image-beta:
if: success() && github.repository == 'porla/porla' && github.ref_name == 'main'
name: Push Docker image (beta)
runs-on: ubuntu-latest
needs: [calc-version,build-app]
permissions:
contents: write
packages: write
pull-requests: read
steps:
- name: Download Docker artifact (linux-amd64)
uses: actions/download-artifact@v3
with:
name: porla-linux-amd64-docker.tar
path: /tmp
- name: Download Docker artifact (linux-arm64)
uses: actions/download-artifact@v3
with:
name: porla-linux-arm64-docker.tar
path: /tmp
- name: Login to the container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load Docker images
run: |
docker load -i /tmp/porla-linux-amd64-docker.tar
docker load -i /tmp/porla-linux-arm64-docker.tar
- name: Push platform specific Docker images
run: |
docker push ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-linux-amd64
docker push ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-linux-arm64
- name: Create Docker manifest
run: |
docker manifest create ghcr.io/porla/porla:beta-latest \
ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-linux-amd64 \
ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-linux-arm64
docker manifest create ghcr.io/porla/porla:beta-${{ needs.calc-version.outputs.shortSha }} \
ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-linux-amd64 \
ghcr.io/porla/porla:${{ needs.calc-version.outputs.shortSha }}-linux-arm64
- name: Push Docker manifest
run: |
docker manifest push ghcr.io/porla/porla:beta-latest
docker manifest push ghcr.io/porla/porla:beta-${{ needs.calc-version.outputs.shortSha }}