4343  steps :
4444    - name : Install PostgreSQL 
4545      run : | 
46-         if [[ ! "${{ inputs.postgres-version }} " =~ ^(14|15|16|17|18)$ ]]; then 
46+         if [[ ! "$INPUT_POSTGRES_VERSION " =~ ^(14|15|16|17|18)$ ]]; then 
4747          echo "::error::postgres-version must be one of: 14, 15, 16, 17, 18." 
4848          exit 1 
4949        fi 
@@ -55,13 +55,13 @@ runs:
5555          echo "$APT_ENTRY" | sudo tee /etc/apt/sources.list.d/pgdg.list 
5656          wget --quiet -O - "$APT_KEY" | sudo apt-key add - 
5757          sudo apt-get update 
58-           sudo apt-get -y install postgresql-${{ inputs.postgres-version }}  
58+           sudo apt-get -y install postgresql-$INPUT_POSTGRES_VERSION  
5959
6060          # The PostgreSQL 17 package for ARM64 automatically starts the 
6161          # PostgreSQL service, occupying the default PostgreSQL port. 
6262          sudo systemctl stop postgresql.service 
6363
64-           PG_BINDIR=$("/usr/lib/postgresql/${{ inputs.postgres-version }} /bin/pg_config" --bindir) 
64+           PG_BINDIR=$("/usr/lib/postgresql/$INPUT_POSTGRES_VERSION /bin/pg_config" --bindir) 
6565          echo "$PG_BINDIR" >> $GITHUB_PATH 
6666
6767        elif [ "$RUNNER_OS" == "Windows" ]; then 
@@ -74,13 +74,13 @@ runs:
7474            echo "$name=" >> $GITHUB_ENV 
7575          done 
7676
77-           choco install postgresql${{ inputs.postgres-version }}  \ 
78-             --params "/Password:${{ inputs.password }} " \ 
77+           choco install postgresql$INPUT_POSTGRES_VERSION  \ 
78+             --params "/Password:$INPUT_PASSWORD " \ 
7979            --ia "--enable-components server,commandlinetools --extract-only 1" \ 
8080            --no-progress 
8181
82-           PG_BINDIR=$("$PROGRAMFILES/PostgreSQL/${{ inputs.postgres-version }} /bin/pg_config.exe" --bindir) 
83-           PG_LIBDIR=$("$PROGRAMFILES/PostgreSQL/${{ inputs.postgres-version }} /bin/pg_config.exe" --libdir) 
82+           PG_BINDIR=$("$PROGRAMFILES/PostgreSQL/$INPUT_POSTGRES_VERSION /bin/pg_config.exe" --bindir) 
83+           PG_LIBDIR=$("$PROGRAMFILES/PostgreSQL/$INPUT_POSTGRES_VERSION /bin/pg_config.exe" --libdir) 
8484
8585          echo "$PG_BINDIR" >> $GITHUB_PATH 
8686          echo "PQ_LIB_DIR=$PG_LIBDIR" >> $GITHUB_ENV 
@@ -94,17 +94,20 @@ runs:
9494          export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 
9595          export HOMEBREW_NO_INSTALL_CLEANUP=1 
9696          export HOMEBREW_NO_INSTALL_UPGRADE=1 
97-           brew install --quiet postgresql@${{ inputs.postgres-version }}  
97+           brew install --quiet postgresql@$INPUT_POSTGRES_VERSION  
9898
9999          # Link PostgreSQL binaries from /usr/local/bin in order to make them 
100100          # available globally. The --overwrite option is required since some 
101101          # GitHub runners come with preinstalled PostgreSQL binaries, and we 
102102          # have to link the required version of PostgreSQL. The unlinking step 
103103          # is needed to suppress "Already linked" warning which is propagated 
104104          # back to users. 
105-           brew unlink --quiet postgresql@${{ inputs.postgres-version }}  
106-           brew link --quiet --overwrite postgresql@${{ inputs.postgres-version }}  
105+           brew unlink --quiet postgresql@$INPUT_POSTGRES_VERSION  
106+           brew link --quiet --overwrite postgresql@$INPUT_POSTGRES_VERSION  
107107        fi 
108+ env :
109+         INPUT_PASSWORD : ${{ inputs.password }} 
110+         INPUT_POSTGRES_VERSION : ${{ inputs.postgres-version }} 
108111      shell : bash 
109112
110113    - name : Setup and start PostgreSQL 
@@ -118,7 +121,7 @@ runs:
118121        # Unfortunately 'initdb' could only receive a password via file on disk 
119122        # or prompt to enter on. Prompting is not an option since we're running 
120123        # in non-interactive mode. 
121-         echo '${{ inputs.password }}'  > $PWFILE 
124+         echo "$INPUT_PASSWORD"  > $PWFILE 
122125
123126        # There are couple of reasons why we need to create a new PostgreSQL 
124127        # database cluster. First and foremost, we have to create a superuser 
@@ -131,7 +134,7 @@ runs:
131134        # [1] https://www.postgresql.org/docs/15/reference-client.html 
132135        initdb \ 
133136          --pgdata="$PGDATA" \ 
134-           --username="${{ inputs.username }} " \ 
137+           --username="$INPUT_USERNAME " \ 
135138          --pwfile="$PWFILE" \ 
136139          --auth="scram-sha-256" \ 
137140          --encoding="$DEFAULT_ENCODING" \ 
@@ -141,9 +144,9 @@ runs:
141144        # Do not create unix sockets since they are created by default in the 
142145        # directory we have no permissions to (owned by system postgres user). 
143146        echo "unix_socket_directories = ''" >> "$PGDATA/postgresql.conf" 
144-         echo "port = ${{ inputs.port }} " >> "$PGDATA/postgresql.conf" 
147+         echo "port = $INPUT_PORT " >> "$PGDATA/postgresql.conf" 
145148
146-         if [ "${{ inputs.ssl }} " = "true" ]; then 
149+         if [ "$INPUT_SSL " = "true" ]; then 
147150          # On Windows, bash runs on top of MSYS2, which automatically converts 
148151          # Unix paths to Windows paths for every argument that appears to be a 
149152          # path. This behavior breaks the openssl invocation because the 
@@ -173,21 +176,27 @@ runs:
173176        # parametrized via action input parameters. 
174177        # 
175178        # [1] https://www.postgresql.org/docs/15/libpq-pgservice.html 
176-         cat <<EOF > "$PGDATA/pg_service.conf" 
177-         [${{ inputs.username }} ] 
179+         cat <<- EOF > "$PGDATA/pg_service.conf" 
180+         [$INPUT_USERNAME ] 
178181        host=localhost 
179-         port=${{ inputs.port }}  
180-         user=${{ inputs.username }}  
181-         password=${{ inputs.password }}  
182-         dbname=${{ inputs.database }}  
182+         port=$INPUT_PORT  
183+         user=$INPUT_USERNAME  
184+         password=$INPUT_PASSWORD  
185+         dbname=$INPUT_DATABASE  
183186        EOF 
184187
185-         if [ "${{ inputs.ssl }} " = "true" ]; then 
188+         if [ "$INPUT_SSL " = "true" ]; then 
186189          echo "sslmode=verify-ca" >> "$PGDATA/pg_service.conf" 
187190          echo "sslrootcert=$PGDATA/server.crt" >> "$PGDATA/pg_service.conf" 
188191        fi 
189192
190193        echo "PGSERVICEFILE=$PGDATA/pg_service.conf" >> $GITHUB_ENV 
194+ env :
195+         INPUT_PORT : ${{ inputs.port }} 
196+         INPUT_USERNAME : ${{ inputs.username }} 
197+         INPUT_PASSWORD : ${{ inputs.password }} 
198+         INPUT_DATABASE : ${{ inputs.database }} 
199+         INPUT_SSL : ${{ inputs.ssl }} 
191200      shell : bash 
192201
193202    - name : Setup PostgreSQL database 
@@ -196,19 +205,21 @@ runs:
196205        # users, utilities and third party applications. There's no way to 
197206        # parametrize the name, so all we can do is to avoid creating a 
198207        # database if provided name is 'postgres'. 
199-         if [ "${{ inputs.database }} " != "postgres" ]; then 
200-           createdb -O "${{ inputs.username }} " "${{ inputs.database }} " 
208+         if [ "$INPUT_DATABASE " != "postgres" ]; then 
209+           createdb -O "$INPUT_USERNAME " "$INPUT_DATABASE " 
201210        fi 
202211env :
212+         INPUT_USERNAME : ${{ inputs.username }} 
213+         INPUT_DATABASE : ${{ inputs.database }} 
203214        PGSERVICE : ${{ inputs.username }} 
204215      shell : bash 
205216
206217    - name : Set action outputs 
207218      run : | 
208-         CONNECTION_URI="postgresql://${{ inputs.username }}:${{ inputs.password }} @localhost:${{ inputs.port }}/${{ inputs.database }} " 
219+         CONNECTION_URI="postgresql://$INPUT_USERNAME:$INPUT_PASSWORD @localhost:$INPUT_PORT/$INPUT_DATABASE " 
209220        CERTIFICATE_PATH="$RUNNER_TEMP/pgdata/server.crt" 
210221
211-         if [ "${{ inputs.ssl }} " = "true" ]; then 
222+         if [ "$INPUT_SSL " = "true" ]; then 
212223          # Although SSLMODE and SSLROOTCERT are specific to libpq options, 
213224          # most third-party drivers also support them. By default libpq 
214225          # prefers SSL but doesn't require it, thus it's important to set 
@@ -219,6 +230,12 @@ runs:
219230        fi 
220231
221232        echo "connection-uri=$CONNECTION_URI" >> $GITHUB_OUTPUT 
222-         echo "service-name=${{ inputs.username }}" >> $GITHUB_OUTPUT 
233+         echo "service-name=$INPUT_USERNAME" >> $GITHUB_OUTPUT 
234+ env :
235+         INPUT_PORT : ${{ inputs.port }} 
236+         INPUT_USERNAME : ${{ inputs.username }} 
237+         INPUT_PASSWORD : ${{ inputs.password }} 
238+         INPUT_DATABASE : ${{ inputs.database }} 
239+         INPUT_SSL : ${{ inputs.ssl }} 
223240      shell : bash 
224241      id : set-outputs 
0 commit comments