Skip to content

Commit 388da94

Browse files
fix(ci): use urllib.parse instead of regex to parse DATABASE_URL
1 parent 1f3650e commit 388da94

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ jobs:
2727
run: |
2828
mkdir -p ~/.dbt
2929
python3 -c "
30-
import os, re
30+
import os
31+
from urllib.parse import urlparse
3132
url = os.environ['DATABASE_URL']
32-
m = re.match(r'postgresql://([^:]+):([^@]+)@([^:/]+):(\d+)/(.+)', url)
33-
user, pwd, host, port, dbname = m.groups()
33+
p = urlparse(url)
3434
content = f'''deliveryops_dbt:
3535
target: dev
3636
outputs:
3737
dev:
3838
type: postgres
39-
host: {host}
40-
user: {user}
41-
password: {pwd}
42-
port: {int(port)}
43-
dbname: {dbname}
39+
host: {p.hostname}
40+
user: {p.username}
41+
password: {p.password}
42+
port: {p.port or 5432}
43+
dbname: {p.path.lstrip('/')}
4444
schema: analytics
4545
threads: 4
4646
sslmode: require

0 commit comments

Comments
 (0)