-
Notifications
You must be signed in to change notification settings - Fork 200
/
entrypoint.sh
executable file
·47 lines (37 loc) · 1.17 KB
/
entrypoint.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
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
if [ -z "$FIREBASE_TOKEN" ] && [ -z "$GCP_SA_KEY" ] && [ -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then
echo "Either FIREBASE_TOKEN or GCP_SA_KEY or GOOGLE_APPLICATION_CREDENTIALS is required to run commands with the firebase cli"
exit 126
fi
if [ -n "$GCP_SA_KEY" ]; then
if echo "$GCP_SA_KEY" | jq empty 2>/dev/null; then
echo "Storing GCP_SA_KEY in /opt/gcp_key.json"
echo "$GCP_SA_KEY" > /opt/gcp_key.json
else
echo "Storing the decoded GCP_SA_KEY in /opt/gcp_key.json"
echo "$GCP_SA_KEY" | base64 -d > /opt/gcp_key.json # If encoded base64 key, decode and save
fi
echo "Exporting GOOGLE_APPLICATION_CREDENTIALS=/opt/gcp_key.json"
export GOOGLE_APPLICATION_CREDENTIALS=/opt/gcp_key.json
fi
if [ -n "$PROJECT_PATH" ]; then
cd "$PROJECT_PATH"
fi
if [ -n "$PROJECT_ID" ]; then
echo "setting firebase project to $PROJECT_ID"
firebase use --add "$PROJECT_ID"
fi
if [ -n "$CONFIG_VALUES" ]; then
echo "Setting config for function"
firebase functions:config:set $CONFIG_VALUES
fi
sh -c "firebase $*"
# response=$(firebase $*)
# if [ $? -eq 0 ]; then
# echo "$response"
# exit 0
# else
# echo "$response"
# exit 1
# fi