generated from trywilco/Anythink-Market-Base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_quest.sh
executable file
·34 lines (27 loc) · 1.04 KB
/
start_quest.sh
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
#!/bin/bash
API_BASE_URL="${API_BASE_URL:="https://engine.wilco.gg"}"
WILCO_ID="`cat .wilco 2> /dev/null`"
sendEvent() {
error=${2//$'\n'/\\n}
body='{"event":"start_quest_script_ran", "metadata": {"success": '$1', "remote": false, "error": "'$error'"}}'
curl -m 5 -X POST $API_BASE_URL/users/$WILCO_ID/event -d "$body" -H 'Content-Type: application/json' &> /dev/null
}
if [[ -z $WILCO_ID ]]; then
printf "Please run the script in the root folder of the repo. Aborting.\n"
exit 1
fi
printf "[= ] Stashing any existing changes ... \n"
git stash &> /dev/null
printf "[== ] Resetting local 'main' branch to 'origin/main' ... \n"
git_output=$((git checkout main && git fetch origin main && git reset --hard origin/main) 2>&1 > /dev/null)
git_exit_code=$?
if ! test "$git_exit_code" -eq 0
then
printf "[==X] ERROR: Could not reset local 'main' branch. Aborting.\n"
sendEvent false "$git_output"
echo "[==X] GIT ERROR: $git_output"
exit 1
fi
printf "[===] SUCCESS: Your local 'main' branch is now up to date with origin.\n"
sendEvent true
exit 0