-
Notifications
You must be signed in to change notification settings - Fork 3
201 lines (169 loc) · 6.89 KB
/
main.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: Actions
on: [push]
env:
BUILD_OUTPUT_FOLDER: 'build/WebGL/WebGL'
PRODUCTION_BUILD_ARTEFACT_NAME: 'viewer'
DEVELOPMENT_BUILD_ARTEFACT_NAME: 'viewer-development'
jobs:
build:
name: '🗺️ Build Netherlands3D Viewer'
# only run this when a commit was pushed to the main branch
if: github.ref_name == 'main'
permissions: { contents: read }
outputs:
buildVersion: ${{ steps.buildUnity.outputs.buildVersion }}
runs-on: ubuntu-latest
steps:
- name: 'Free Disk Space'
# see: https://github.com/jlumbroso/free-disk-space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
- name: 'Checkout code from repository'
# see: https://github.com/actions/checkout
uses: actions/checkout@v4
with: { lfs: true }
- name: 'Cache Library folder - restore and track'
# see: https://github.com/actions/cache
uses: actions/cache@v4
with:
path: 'Library'
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
- name: 'Build Unity project to WebGL'
id: buildUnity # used when building the docker container to get the version number from
# See https://game.ci/docs/github/getting-started
uses: game-ci/unity-builder@v4
env:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: WebGL
unityVersion: auto
# A custom specific image can be used (source: https://github.com/game-ci/unity-builder/blob/main/action.yml):
# customImage: unityci/editor:ubuntu-2022.3.8f1-webgl-2
- name: 'Upload artifact to build pipeline'
# see: https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with: { name: '${{ env.PRODUCTION_BUILD_ARTEFACT_NAME }}', path: '${{ env.BUILD_OUTPUT_FOLDER }}' }
build-development:
name: '🐞 Build Development Netherlands3D Viewer'
permissions: { contents: read }
runs-on: ubuntu-latest
steps:
- name: 'Free Disk Space'
# see: https://github.com/jlumbroso/free-disk-space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true
- name: 'Checkout code from repository'
# see: https://github.com/actions/checkout
uses: actions/checkout@v4
with: { lfs: true }
- name: 'Cache Library folder - restore and track'
# see: https://github.com/actions/cache
uses: actions/cache@v4
with:
path: 'Library'
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
- name: 'Build Unity project to WebGL'
# See https://game.ci/docs/github/getting-started
uses: game-ci/unity-builder@v4
env:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: WebGL
customParameters: '-Development -AllowDebugging'
# A custom specific image can be used (source: https://github.com/game-ci/unity-builder/blob/main/action.yml):
# customImage: unityci/editor:ubuntu-2022.3.8f1-webgl-2
unityVersion: auto
- name: 'Upload artifact to build pipeline'
# see: https://github.com/actions/download-artifact
uses: actions/upload-artifact@v4
with: { name: '${{ env.DEVELOPMENT_BUILD_ARTEFACT_NAME }}', path: '${{ env.BUILD_OUTPUT_FOLDER }}' }
build-docker-image:
name: '🐳 Build and Publish Docker Image'
# only run this when a commit was pushed to the main branch
if: github.ref_name == 'main'
# only run this after the 'build' stage has successfully completed
needs: [ 'build' ]
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: 'Checkout repository'
# see: https://github.com/actions/checkout
uses: actions/checkout@v4
with: { lfs: true }
- name: 'Download built viewer'
# see: https://github.com/actions/download-artifact
uses: actions/download-artifact@v4
with: { name: '${{ env.PRODUCTION_BUILD_ARTEFACT_NAME }}', path: '${{ env.BUILD_OUTPUT_FOLDER }}' }
- name: 'Show Version'
run: 'echo "Version: ${{ needs.build.outputs.buildVersion }}"'
- name: 'Docker: Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Docker: Build and push image'
if: github.ref_name == 'main' # double ensure this is only on main, in case of debugging
uses: docker/build-push-action@v5
with:
context: .
file: .docker/Dockerfile
push: true
build-args: |
SOURCE_PATH=${{ env.BUILD_OUTPUT_FOLDER }}
tags: |
ghcr.io/netherlands3d/twin:${{ needs.build.outputs.buildVersion }}
ghcr.io/netherlands3d/twin:latest
deploy:
name: '🌐 Deploy the viewer to Github Pages'
# only run this when a commit was pushed to the main branch
if: github.ref_name == 'main'
# only run this after the 'build' stage has successfully completed
needs: build
permissions:
pages: write
id-token: write
environment:
name: 'github-pages'
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: 'Download built viewer'
# see: https://github.com/actions/download-artifact
uses: actions/download-artifact@v4
with: { name: '${{ env.PRODUCTION_BUILD_ARTEFACT_NAME }}', path: '${{ env.BUILD_OUTPUT_FOLDER }}' }
- name: 'Prepare artefact for deployment'
if: github.ref_name == 'main' # double ensure this is only on main, in case of debugging
# see: https://github.com/actions/upload-pages-artifact
uses: actions/upload-pages-artifact@v3
with:
path: '${{ env.BUILD_OUTPUT_FOLDER }}'
- name: 'Deploy to GitHub Pages'
if: github.ref_name == 'main' # double ensure this is only on main, in case of debugging
id: deployment
# see: https://github.com/actions/deploy-pages
uses: actions/deploy-pages@v4