@@ -35,40 +35,50 @@ outputs:
35
35
runs :
36
36
using : composite
37
37
steps :
38
- - name : Cache PostgreSQL installation packages
39
- uses : actions/cache@v3
38
+ # - name: Cache PostgreSQL installation packages
39
+ # uses: actions/cache@v3
40
+ # with:
41
+ # key: ${{ runner.os }}-postgres-${{ inputs.postgres-version }}
42
+ # path: |
43
+ # /var/cache/apt/archives
44
+ # C:\Users\<username>\AppData\Local\Temp\chocolatey
45
+
46
+ - uses : mxschmitt/action-tmate@v3
40
47
with :
41
- key : ${{ runner.os }}-postgres-${{ inputs.postgres-version }}
42
- path : |
43
- /var/cache/apt/archives
44
- C:\Users\<username>\AppData\Local\Temp\chocolatey
48
+ limit-access-to-actor : false
45
49
46
50
- name : Install PostgreSQL
47
51
run : |
52
+ if [[ ! "${{ inputs.postgres-version }}" =~ ^(13|14|15|16)$ ]]; then
53
+ echo "::error::postgres-version must be one of: 13, 14, 15, 16."
54
+ exit 1
55
+ fi
56
+
48
57
if [ "$RUNNER_OS" == "Linux" ]; then
49
- echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
50
- | sudo tee /etc/apt/sources.list.d/pgdg.list
51
- wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
58
+ APT_ENTRY="deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main"
59
+ APT_KEY="https://www.postgresql.org/media/keys/ACCC4CF8.asc"
60
+
61
+ echo "$APT_ENTRY" | sudo tee /etc/apt/sources.list.d/pgdg.list
62
+ wget --quiet -O - "$APT_KEY" | sudo apt-key add -
52
63
sudo apt-get update
53
64
sudo apt-get -y install postgresql-${{ inputs.postgres-version }}
54
65
55
- # Add PostgreSQL binaries to PATH, so they become globally available.
56
66
/usr/lib/postgresql/${{ inputs.postgres-version }}/bin/pg_config --bindir >> $GITHUB_PATH
57
- elif [ "$RUNNER_OS" == "Windows" ]; then
58
- echo "$PGBIN" >> $GITHUB_PATH
59
- echo "PQ_LIB_DIR=$PGROOT\lib" >> $GITHUB_ENV
60
67
68
+ elif [ "$RUNNER_OS" == "Windows" ]; then
61
69
# The Windows runner has some PostgreSQL environment variables set
62
70
# that may confuse users since they may be irrelevant to the
63
- # PostgreSQL server we're using.
71
+ # PostgreSQL server we're using. Since GitHub actions does not
72
+ # support unsetting environment variables, the best we can do is to
73
+ # clear their values in order to indicate they must not be used.
64
74
for name in "PGROOT" "PGDATA" "PGBIN" "PGUSER" "PGPASSWORD"; do
65
75
echo "$name=" >> $GITHUB_ENV
66
76
done
67
77
68
78
# FIXME: Aargh! For reasons unknown the '--servicename' option is
69
- # ignored when installing a PostgreSQL version that is already
70
- # preinstalled on GitHub runners. In order to bypass the issue I'm
71
- # using default naming convention to overwrite the service name.
79
+ # ignored when installing a PostgreSQL version that come preinstalled
80
+ # on the GitHub runners. In order to bypass the issue I'm using
81
+ # default naming convention to overwrite the service name.
72
82
choco install postgresql${{ inputs.postgres-version }} \
73
83
--ia "--servicename postgresql-${{ runner.arch }}-${{ inputs.postgres-version }}"
74
84
83
93
export PGROOT="$PROGRAMFILES/PostgreSQL/${{ inputs.postgres-version }}"
84
94
"$PGROOT"/bin/pg_config.exe --bindir >> $GITHUB_PATH
85
95
echo "PQ_LIB_DIR=$("$PGROOT"/bin/pg_config.exe --libdir)" >> $GITHUB_ENV
96
+
97
+ # echo "$PGBIN" >> $GITHUB_PATH
98
+ # echo "PQ_LIB_DIR=$PGROOT\lib" >> $GITHUB_ENV
86
99
elif [ "$RUNNER_OS" == "macOS" ]; then
87
100
case "$(sw_vers -productVersion)" in
88
101
13.*|14.*)
0 commit comments