4141 - name : Setup and start PostgreSQL
4242 run : |
4343 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
4450
4551 # There are couple of reasons why we need to create a new PostgreSQL
4652 # database cluster. First and foremost, we have to create a superuser
5359 # [1] https://www.postgresql.org/docs/15/reference-client.html
5460 initdb \
5561 --username="${{ inputs.username }}" \
62+ --pwfile="$PWFILE" \
63+ --auth="scram-sha-256" \
5664 --encoding="UTF-8" \
5765 --locale="en_US.UTF-8" \
5866 --no-instructions
@@ -69,13 +77,14 @@ runs:
6977 # PGHOST is required for Linux/macOS because we turned off unix sockets
7078 # and they use them by default.
7179 #
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.
7482 #
7583 # [1] https://www.postgresql.org/docs/15/reference-client.html
7684 echo "PGHOST=localhost" >> $GITHUB_ENV
7785 echo "PGPORT=${{ inputs.port }}" >> $GITHUB_ENV
7886 echo "PGUSER=${{ inputs.username }}" >> $GITHUB_ENV
87+ echo "PGPASSWORD=${{ inputs.password }}" >> $GITHUB_ENV
7988 echo "PGDATABASE=${{ inputs.database }}" >> $GITHUB_ENV
8089 shell : bash
8190
0 commit comments