forked from tibotiber/hasura-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·45 lines (34 loc) · 1.07 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
#!/bin/sh -l
set -e
if [ -z "$HASURA_ENDPOINT" ]; then
echo "HASURA_ENDPOINT is required to run commands with the hasura cli"
exit 126
fi
command="hasura $* --endpoint '$HASURA_ENDPOINT'"
if [ -n "$HASURA_ADMIN_SECRET" ]; then
command="$command --admin-secret '$HASURA_ADMIN_SECRET'"
fi
if [ -n "$DATABASE_NAME" ]; then
command="$command --database-name '$DATABASE_NAME'"
fi
if [ -n "$HASURA_WORKDIR" ]; then
cd $HASURA_WORKDIR
fi
# create mock config file if none found
if [ ! -f config.yaml ]; then
touch config.yaml
fi
if [ -n "$HASURA_ENGINE_VERSION" ]; then
hasura update-cli --version $HASURA_ENGINE_VERSION
else
DETECTED_HASURA_ENGINE_VERSION=$(curl -s "$HASURA_ENDPOINT"/v1/version \
| jq .version \
| awk '{split($0,a,"-"); print a[1]}' \
| awk '{split($0,a,"\""); print a[2]}')
if [ -n "$DETECTED_HASURA_ENGINE_VERSION" ]; then
hasura update-cli --version $DETECTED_HASURA_ENGINE_VERSION
fi
fi
# secrets can be printed, they are protected by Github Actions
echo "Executing $command from ${HASURA_WORKDIR:-./}"
sh -c "$command"