-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (131 loc) · 4.61 KB
/
buildfrontend.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
name: Build frontend
on:
push:
branches:
- develop
- master
workflow_dispatch:
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
# Introduces slugified variables; eg "master" instead of "refs/heads/master"
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Create timestamp for release tag-name
id: tag_name
run: echo "tag_name=$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
- name: Cut a release, for download by Ansible
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_name.outputs.tag_name }}
release_name: Frontend (${{ env.GITHUB_REF_SLUG }} - ${{ env.GITHUB_SHA_SHORT }})
draft: false
prerelease: false
frontend-build:
name: Build Frontend
needs: create-release
runs-on: ubuntu-latest
env:
LEIN_ROOT: nbd
JVM_OPTS: -Xmx3200m
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v2
# Introduces slugified variables; eg "master" instead of "refs/heads/master"
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Conditionally set build profile based on branch (master)
if: endswith(github.ref, '/master')
run: |
echo "PROFILE=min" >> $GITHUB_ENV
- name: Conditionally set build profile based on branch (develop)
if: ${{ !endswith(github.ref, '/master') }}
run: |
echo "PROFILE=mindev" >> $GITHUB_ENV
- name: Set up Java for Clojure
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set up / restore caching
uses: actions/cache@v2
with:
path: node_modules
key: npm-packages-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-packages-
- name: Cache maven deps as well
uses: actions/cache@v2
with:
path: ~/.m2
key: m2-deps-${{ hashFiles('shadow-cljs.edn') }}
restore-keys: |
m2-deps-
- name: Install Dependencies
run: yarn
- name: Build Blueprint CSS
run: yarn build-blueprint-css
- name: Style build
run: yarn build-css
- name: Components build
run: yarn build-js
- name: Worker build
run: yarn build-worker
- name: Build project
run: npx shadow-cljs release ${{ env.PROFILE }}
- name: Expand cache-busting app.js tag
run: |
app_tag=$(jq '.[0]."output-name"' 'resources/public/js/manifest.json')
app_tag=$(echo $app_tag | sed 's/^"//;s/"$//')
sed -i "s/app.js/$app_tag/" 'resources/public/index.html'
- name: Ensure archive is group-writeable for safe extraction
run: chmod -R g+w resources/public
- run: tar -c -z -v -C resources/public -f frontend.tgz .
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: "frontend/frontend.tgz"
asset_name: frontend.tgz
asset_content_type: application/gzip
build-carbon-abatement-sidebar:
name: Build Carbon Abatement Sidebar
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'yarn'
cache-dependency-path: 'backend/carbonabatementsidebar/frontend/yarn.lock'
- name: Install Dependencies and Build
working-directory: 'backend/carbonabatementsidebar/frontend'
run: |
yarn install
yarn build
- name: Ensure static archive is group-writeable for safe extraction
run: chmod -R g+w backend/carbonabatementsidebar/static
- name: Zip Static Files
run: tar -czv -C backend/carbonabatementsidebar/static -f backend/carbonabatementsidebar/static.tgz .
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: backend/carbonabatementsidebar/static.tgz
asset_name: carbonabatementsidebar-static.tgz
asset_content_type: application/gzip