41
41
- name : Setup and start PostgreSQL
42
42
run : |
43
43
export PGDATA="$RUNNER_TEMP/pgdata"
44
+ export PWFILE="$RUNNER_TEMP/pwfile"
45
+
46
+ # Unfortunately 'initdb' could only receive a password via file on disk
47
+ # or prompt to enter on. Prompting is not an option since we're running
48
+ # in non-interactive mode.
49
+ echo '${{ inputs.password }}' > $PWFILE
44
50
45
51
# There are couple of reasons why we need to create a new PostgreSQL
46
52
# database cluster. First and foremost, we have to create a superuser
53
59
# [1] https://www.postgresql.org/docs/15/reference-client.html
54
60
initdb \
55
61
--username="${{ inputs.username }}" \
62
+ --pwfile="$PWFILE" \
63
+ --auth="scram-sha-256" \
56
64
--encoding="UTF-8" \
57
65
--locale="en_US.UTF-8" \
58
66
--no-instructions
@@ -69,13 +77,14 @@ runs:
69
77
# PGHOST is required for Linux/macOS because we turned off unix sockets
70
78
# and they use them by default.
71
79
#
72
- # PGPORT, PGUSER and PGDATABASE are required because they could be
73
- # parametrized via action input parameters.
80
+ # PGPORT, PGUSER, PGPASSWORD and PGDATABASE are required because they
81
+ # could be parametrized via action input parameters.
74
82
#
75
83
# [1] https://www.postgresql.org/docs/15/reference-client.html
76
84
echo "PGHOST=localhost" >> $GITHUB_ENV
77
85
echo "PGPORT=${{ inputs.port }}" >> $GITHUB_ENV
78
86
echo "PGUSER=${{ inputs.username }}" >> $GITHUB_ENV
87
+ echo "PGPASSWORD=${{ inputs.password }}" >> $GITHUB_ENV
79
88
echo "PGDATABASE=${{ inputs.database }}" >> $GITHUB_ENV
80
89
shell : bash
81
90
0 commit comments