Skip to content

Commit 1903fa1

Browse files
authored
Refactor PostgreSQL dependency detection to use array (#283)
1 parent 00f7992 commit 1903fa1

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

bin/release

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,25 @@ echo "---"
88

99
dependencies_file_path="${BUILD_DIR}/.heroku/sbt-dependency-classpath.log"
1010

11-
if [[ -f "${dependencies_file_path}" ]] && (
12-
grep -q "com/impossibl/pgjdbc-ng" "${dependencies_file_path}" ||
13-
grep -q "org/postgresql" "${dependencies_file_path}" ||
14-
grep -q "skunk-core" "${dependencies_file_path}" ||
15-
grep -q "postgresql-async" "${dependencies_file_path}" ||
16-
grep -q "quill-ndbc-postgres" "${dependencies_file_path}"
17-
); then
11+
# Auto-provision Heroku Postgres if PostgreSQL dependencies are detected.
12+
# Only applicable to accounts created before May 15, 2023 or accounts with auto-provisioning enabled.
13+
# See: https://devcenter.heroku.com/articles/scala-support#postgres-auto-provisioning
14+
if [[ -f "${dependencies_file_path}" ]]; then
15+
postgresql_dependencies=(
16+
"com/impossibl/pgjdbc-ng" # https://impossibl.github.io/pgjdbc-ng/
17+
"org/postgresql" # https://jdbc.postgresql.org/
18+
"skunk-core" # https://typelevel.org/skunk/
19+
"postgresql-async" # https://github.com/postgresql-async/postgresql-async
20+
"quill-ndbc-postgres" # https://github.com/zio/zio-quill
21+
)
1822

19-
echo "addons:"
20-
echo " - heroku-postgresql"
23+
for dependency in "${postgresql_dependencies[@]}"; do
24+
if grep -q "${dependency}" "${dependencies_file_path}"; then
25+
echo "addons:"
26+
echo " - heroku-postgresql"
27+
break
28+
fi
29+
done
2130
fi
2231

2332
if [[ ! -f "${BUILD_DIR}/Procfile" ]]; then

0 commit comments

Comments
 (0)