-
Notifications
You must be signed in to change notification settings - Fork 11
/
entrypoint.sh
executable file
·68 lines (56 loc) · 2.14 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
# set up nvm in this script
. "${NVM_DIR}/nvm.sh"
if [ -n "${PRIVATE_KEY}" ]; then
echo "${PRIVATE_KEY}" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
fi
if [ -n "${PUBLIC_KEY}" ]; then
echo "${PUBLIC_KEY}" > /root/.ssh/id_rsa.pub
fi
if [ -z "${TERMINUS_TOKEN}" ]; then
echo "TERMINUS_TOKEN is not set, skipping terminus setup.";
else
echo "TERMINUS_TOKEN is set. Logging In.";
terminus auth:login --machine-token="${TERMINUS_TOKEN}"
fi
# Set git user.name if GIT_USER_NAME env variable is present
if [ -n "${GIT_USER_NAME}" ]; then
echo "Setting Git user.name to ${GIT_USER_NAME}"
git config --global user.name "${GIT_USER_NAME}"
fi
# Set git user.email if GIT_USER_EMAIL env variable is present
if [ -n "${GIT_USER_EMAIL}" ]; then
echo "Setting Git user.email to ${GIT_USER_EMAIL}"
git config --global user.email "${GIT_USER_EMAIL}"
fi
# Set custom composer configs if COMPOSER_CONFIG env variable is present
if [ -n "${COMPOSER_CONFIG}" ]; then
echo "Setting composer configs - ${COMPOSER_CONFIG}"
/usr/local/bin/composer config -g "${COMPOSER_CONFIG}"
fi
# Some CI/CD tools require cache to be in the working directory and not
# in default Composer or npm locations, so we use custom paths
# In GitLab, BUILD_CACHE_DIR should be set to ${CI_PROJECT_DIR}
if [ -n "${BUILD_CACHE_DIR}" ]; then
# Set a local cache path for composer, so we can cache between builds and make things faster
echo "Setting composer cache directory to ${BUILD_CACHE_DIR}/.composer-cache"
/usr/local/bin/composer config -g cache-files-dir "${BUILD_CACHE_DIR}/.composer-cache"
# Set a local cache path for npm, so we can cache between builds and make things faster
# node_modules_cache was choosen since we already ignore *node_modules* in rsync-excludes
echo "Setting npm cache directory to ${BUILD_CACHE_DIR}/node_modules_cache"
npm config set cache "${BUILD_CACHE_DIR}/node_modules_cache" --global
fi
# Output versions of various installed packages
set -x
php --version
composer --version
node --version
npm --version
grunt --version
gulp --version
bower --version
yarn --version
php /usr/local/bin/wp-cli.phar --allow-root --version
set +x
exec "$@"