-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
32 lines (26 loc) · 954 Bytes
/
deploy.sh
File metadata and controls
32 lines (26 loc) · 954 Bytes
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
#!/usr/bin/env bash
GITHUB_TOKEN="${GITHUB_TOKEN?}"
REPO="${GITHUB_REPO?}"
TAG="${GITHUB_TAG?}"
ARTIFACT_NAME="observatory-x86_64-unknown-linux-gnu.tar.gz"
SYSTEMD_SERVICE="observatory"
BINARY_NAME="observatory"
./${BINARY_NAME} --version
systemctl --user status ${SYSTEMD_SERVICE}
asset_url=$(
curl -L \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${REPO}/releases/tags/${TAG}" \
| jq -r ".assets | .[] | select(.name==\"$ARTIFACT_NAME\") | .url"
)
echo "asset URL: ${asset_url}"
curl -L \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/octet-stream" \
"${asset_url}" \
-o "${ARTIFACT_NAME}" || exit 1
tar --extract --file ${ARTIFACT_NAME} ${BINARY_NAME} && \
rm ${ARTIFACT_NAME} && \
systemctl --user restart ${SYSTEMD_SERVICE} || exit 1
systemctl --user status ${SYSTEMD_SERVICE} || exit 1