installation/download-mastofe-build.sh: Add mastofe CI-artifacts download
[akkoma] / installation / download-mastofe-build.sh
1 #!/bin/sh
2 project_id="74"
3 project_branch="rebase/glitch-soc"
4 static_dir="instance/static"
5 # For bundling:
6 # project_branch="pleroma"
7 # static_dir="priv/static"
8
9 if [[ ! -d "${static_dir}" ]]
10 then
11 echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
12 exit 1
13 fi
14
15 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-)"
16
17 echo "branch:${project_branch}"
18 echo "Last-Modified:${last_modified}"
19
20 artifact="mastofe.zip"
21
22 if [[ -e mastofe.timestamp ]] && [[ "${last_modified}" != "" ]]
23 then
24 if [[ "$(cat mastofe.timestamp)" == "${last_modified}" ]]
25 then
26 echo "MastoFE is up-to-date, exiting…"
27 exit 0
28 fi
29 fi
30
31 curl -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
32
33 # TODO: Update the emoji as well
34 rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
35 unzip -q "${artifact}" || exit
36
37 cp public/assets/sw.js "${static_dir}/sw.js" || exit
38 cp -r public/packs "${static_dir}/packs" || exit
39
40 echo "${last_modified}" > mastofe.timestamp
41 rm -fr public
42 rm -i "${artifact}"