forked from ProtonVPN/android-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint
executable file
·80 lines (56 loc) · 2.29 KB
/
entrypoint
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -eo pipefail
source "${HOME}/.bashrc"
if [ -n "$CI_SERVER_HOST" ]; then
# Gitlab put the code here...
cd "$CI_PROJECT_DIR";
# https://gitlab.com/gitlab-org/gitlab-runner/issues/1380
if [ -f ~/lockfilerun ]; then
exit 0;
fi
ls -lha
# debug env
env | grep 'CI_' || true
echo 123 > ~/lockfilerun
fi
if [ -f "$HOME/app/.env" ]; then
echo '[image] load local .env';
source "$HOME/app/.env";
fi
#export GRADLE_USER_HOME="${HOME}/.gradle"
if [ -f "$GRADLE_USER_HOME" ]; then
chmod +x ./gradlew
fi
if [ -n "$SSH_PRIVATE_KEY" ]; then
echo "[run] load private ssh key"
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
git config --global user.email "$GIT_CI_EMAIL"
git config --global user.name "$GIT_CI_USERNAME"
git config --global url."https://".insteadOf git://
# Ensure we can push to github via the image as we need a proxy
mkdir "$HOME/.ssh" 2> /dev/null
cat <<EOF > "$HOME/.ssh/config"
Host github.com
Hostname ssh.github.com
User git
Port 443
ProxyCommand connect-proxy -H $http_proxy %h %p
EOF
ssh-keyscan -t rsa ${CI_SERVER_HOST} > "$HOME/.ssh/known_hosts"
## ssh-keyscan doesn't support proxies so we can't fetch the fingerprint online
cat <<EOF >> "$HOME/.ssh/known_hosts"
# ssh.github.com:443 SSH-2.0-babeld-2e9d163d
[ssh.github.com]:443 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
EOF
else
echo "[WARNING] no variable SSH_PRIVATE_KEY available. You will not be able to push to github or push to gitlab"
fi
if [ -n "$http_proxy" ]; then
proxyHost="$(echo "${http_proxy##http://}" | cut -d':' -f1)";
proxyPort="$(echo "${http_proxy##http://}" | cut -d':' -f2)";
noProxyHost="$(echo "$no_proxy" | tr ',' '|')"
export JAVA_TOOL_OPTIONS="-Dhttp.proxyHost=$proxyHost -Dhttp.proxyPort=$proxyPort -Dhttps.proxyHost=$proxyHost -Dhttps.proxyPort=$proxyPort -Dhttp.nonProxyHosts=$noProxyHost";
fi
export GRADLE_USER_HOME="${CI_PROJECT_DIR:-$PWD}/.gradle"
"$@"