-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (153 loc) · 5.54 KB
/
build-site-and-publish-to-ghpages.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
# For more information see: https://github.com/marketplace/actions/deploy-to-github-pages
name: Build Webpage and Deploy to Github Pages and Docker
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
on:
workflow_dispatch:
push:
branches:
- main
# schedule:
# # Run every 6 days to keep caches alive
# - cron: '0 0 */6 * *'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
# Default to bash
defaults:
run:
shell: bash
jobs:
build-website:
concurrency: ci-build-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Setup Protocol Buffer Compiler
uses: arduino/setup-protoc@v3
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip" # caching pip dependencies
- name: Install Betterproto
run: pip install "betterproto[compiler]==2.0.0b7"
# - name: Install Cython
# run: pip install Cython
- name: Install and Build 🔧 # This project is built using pnpm and outputs the result to the 'dist' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
run: |
pnpm install
pnpm run compile:proto
pnpm run build
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: project
path: |
./
!*node_modules*
!.editorconfig
!*.git*
overwrite: true
deploy-frontend:
concurrency: ci-frontend-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
needs: build-website
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: project
merge-multiple: true
path: ./
- name: Copy Internal Page for Debugging on Github Pages
run: cp -r ./rov-internal-website/build ./frontend/build/internal
- name: Deploy Site to Github Pages Website Hosting 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: frontend/build # The folder the action should deploy.
branch: gh-pages # The branch the action should deploy to.
deploy-docker:
concurrency: ci-docker-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
needs: build-website
runs-on: ubuntu-latest
strategy:
matrix:
project: ["rov-web"]
platforms: ["linux/arm/v7,linux/arm64/v8"]
steps:
- uses: actions/download-artifact@v4
with:
name: project
path: ./
- name: Prepare
id: prepare
run: |
# Deploy image with the name of the branch, if the build is a git tag, replace tag with the tag name.
# If git tag matches semver, append latest tag to the push.
DOCKER_IMAGE=${DOCKER_USERNAME:-kywm}/${{ matrix.project }}
VERSION=${GITHUB_REF##*/}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "buildx_args=\
--build-arg GIT_DESCRIBE_TAGS=$(git describe --tags --long --always) \
--build-arg VITE_APP_GIT_DESCRIBE=$(git describe --long --always --dirty --all) \
--cache-from 'type=local,src=/tmp/.buildx-cache' \
--cache-to 'type=local,dest=/tmp/.buildx-cache' \
${TAGS} \
--file Dockerfile ./" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Cache Docker layers
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-buildx-cache
restore-keys: |
${{ runner.os }}-docker-buildx-cache
- name: Docker Buildx (build)
run: |
# Pull latest version of image to help with build speed
for platform in $(echo ${{ matrix.platforms }} | tr ',' '\n'); do
docker pull --platform ${platform} ${DOCKER_USERNAME:-kywm}/${{ matrix.project }}:working || true
done
docker buildx build \
--output "type=image,push=true" \
--platform ${{ matrix.platforms }} \
${{ steps.prepare.outputs.buildx_args }}