Merge remote-tracking branch 'origin/develop' into global-status-expiration
[akkoma] / installation / download-mastofe-build.sh
1 #!/bin/sh
2 # Pleroma: A lightweight social networking server
3 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
4 # SPDX-License-Identifier: AGPL-3.0-only
5 project_id="74"
6 project_branch="rebase/glitch-soc"
7 static_dir="instance/static"
8 # For bundling:
9 # project_branch="pleroma"
10 # static_dir="priv/static"
11
12 if [[ ! -d "${static_dir}" ]]
13 then
14 echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
15 exit 1
16 fi
17
18 last_modified="$(curl -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
19
20 echo "branch:${project_branch}"
21 echo "Last-Modified:${last_modified}"
22
23 artifact="mastofe.zip"
24
25 if [[ -e mastofe.timestamp ]] && [[ "${last_modified}" != "" ]]
26 then
27 if [[ "$(cat mastofe.timestamp)" == "${last_modified}" ]]
28 then
29 echo "MastoFE is up-to-date, exiting…"
30 exit 0
31 fi
32 fi
33
34 curl -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
35
36 # TODO: Update the emoji as well
37 rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
38 unzip -q "${artifact}" || exit
39
40 cp public/assets/sw.js "${static_dir}/sw.js" || exit
41 cp -r public/packs "${static_dir}/packs" || exit
42
43 echo "${last_modified}" > mastofe.timestamp
44 rm -fr public
45 rm -i "${artifact}"