-
Notifications
You must be signed in to change notification settings - Fork 4
164 lines (140 loc) · 4.69 KB
/
release.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
name: Release docker image
on:
release:
types: [created]
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
runs-on: ubuntu-latest
permissions:
packages: write # required to publish docker image
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CI: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get admin and front git cache key
run: |
echo "ADMIN_CACHE_KEY=$(git submodule status ./admin)" >> $GITHUB_ENV
echo "FRONT_CACHE_KEY=$(git submodule status ./front)" >> $GITHUB_ENV
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://[email protected]/
- name: Cache admin
id: cache-admin
uses: actions/cache@v4
with:
path: ./admin/build
key: admin-${{ env.ADMIN_CACHE_KEY }}
- name: Setup node for admin
if: steps.cache-admin.outputs.cache-hit != 'true'
uses: actions/setup-node@v4
with:
node-version-file: './admin/.nvmrc'
cache: 'npm'
cache-dependency-path: './admin/package-lock.json'
- name: Install admin dependencies
if: steps.cache-admin.outputs.cache-hit != 'true'
working-directory: ./admin
run: |
npm ci --legacy-peer-deps --no-audit
- name: Build admin
if: steps.cache-admin.outputs.cache-hit != 'true'
working-directory: ./admin
run: |
cp ../conf/admin.env .env
npx react-scripts --openssl-legacy-provider build
- name: Cache front
id: cache-front
uses: actions/cache@v4
with:
path: ./front/build
key: front-${{ env.FRONT_CACHE_KEY }}
- name: Setup node for front
if: steps.cache-front.outputs.cache-hit != 'true'
uses: actions/setup-node@v4
with:
node-version-file: './front/.nvmrc'
cache: 'npm'
cache-dependency-path: './front/package-lock.json'
- name: Install front dependencies
if: steps.cache-front.outputs.cache-hit != 'true'
working-directory: ./front
run: |
npm ci --no-audit --only production
- name: Build front
if: steps.cache-front.outputs.cache-hit != 'true'
working-directory: ./front
run: |
npm run build
- uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker dev
id: meta-dev
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-dev
- name: Build and push Docker image dev
uses: docker/build-push-action@v6
with:
context: .
file: .docker/backend/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta-dev.outputs.tags }}
labels: ${{ steps.meta-dev.outputs.labels }}
target: dev
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: .docker/backend/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: prod
attach_install_release:
runs-on: ubuntu-latest
needs: [ release ]
permissions:
contents: write # required to attach zip to release
if: ${{ (github.event_name == 'release' && github.event.action == 'created') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare install.zip
run: |
cd install
mkdir -p terra_visu/var terra_visu/public
cp * ./terra_visu 2>/dev/null || :
cp -r ./conf ./terra_visu
zip -r ../install.zip terra_visu/
- name: Attach zip archive as release binary
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'install.zip'