Skip to content

Commit 4b341fe

Browse files
authored
Merge pull request #78 from OpenConext/bugfix/fix-init-ci
Bugfix: Init script doesnt work for ci
2 parents a38e6d3 + 309f399 commit 4b341fe

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

core/scripts/init.sh

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,35 @@ printf "\n"
1616
# Check that engine and mariadb are already running; containers must be started via ./start-dev-env.sh first
1717
engine_running=$(docker compose ps -q --status running engine mariadb | wc -l)
1818
if [[ "$engine_running" -lt 2 ]]; then
19-
echo -e "${RED}ERROR: engine and/or mariadb are not running.${NOCOLOR}"
20-
echo -e "${ORANGE}Please start the environment first by running:${NOCOLOR}"
21-
echo -e " ${GREEN}./start-dev-env.sh${NOCOLOR}"
22-
echo -e "Then re-run this script once the containers are up."
23-
exit 1
19+
if [[ "${GITHUB_ACTIONS}" == "true" ]]; then
20+
docker compose up -d engine mariadb
21+
echo -e "${ORANGE}Bringing up the EB production container for migrations${NOCOLOR}"
22+
else
23+
echo -e "${RED}ERROR: engine and/or mariadb are not running.${NOCOLOR}"
24+
echo -e "${ORANGE}Please start the environment first by running:${NOCOLOR}"
25+
echo -e " ${GREEN}./start-dev-env.sh${NOCOLOR}"
26+
echo -e "Then re-run this script once the containers are up."
27+
exit 1
28+
fi
2429
fi
2530
echo -e "${ORANGE}Using the currently running engine container for migrations${NOCOLOR}"
2631
docker compose exec engine timeout 300 bash -c 'while [[ "$(curl -k -s -o /dev/null -w ''%{http_code}'' localhost/internal/info)" != "200" ]]; do sleep 5; done' || false
2732

2833
echo
2934
echo -e "${ORANGE}Initializing EB database$NOCOLOR ${VINKJE}"
3035
echo
31-
echo "Running database migrations"
32-
cmd='docker compose exec engine /var/www/html/bin/console doctrine:migrations:migrate --no-interaction'
33-
${cmd}
36+
if [[ "${GITHUB_ACTIONS}" == "true" ]]; then
37+
echo "Checking if the database is already present"
38+
if ! docker compose exec engine /var/www/html/bin/console doctrine:schema:validate -q --skip-mapping --env=prod > /dev/null 2>&1
39+
then
40+
echo "Creating the database schema"
41+
docker compose exec engine /var/www/html/bin/console doctrine:schema:update --force -q
42+
fi
43+
else
44+
echo "Running database migrations"
45+
cmd='docker compose exec engine /var/www/html/bin/console doctrine:migrations:migrate --no-interaction'
46+
${cmd}
47+
fi
3448

3549
echo "Clearing the cache"
3650
docker compose exec engine /var/www/html/bin/console cache:clear -n --env=prod
@@ -44,6 +58,14 @@ do
4458
done
4559
echo -e " ${VINKJE}"
4660

61+
if [[ "${GITHUB_ACTIONS}" == "true" ]]; then
62+
echo
63+
echo -e "${ORANGE}Bring up the core containers${NOCOLOR} ${VINKJE}"
64+
echo
65+
docker compose --profile oidc up -d --wait
66+
echo
67+
fi
68+
4769
echo -e "${ORANGE}Adding the manage entities${NOCOLOR} ${VINKJE}"
4870
printf "\n"
4971
for i in "$CWD"/*.json; do

0 commit comments

Comments
 (0)