-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
107 lines (98 loc) · 4.5 KB
/
Copy pathaction.yml
File metadata and controls
107 lines (98 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: PGXN Postgres Action
description: Install, configure, and start a PostgreSQL cluster for testing extensions.
author: David E. Wheeler
branding:
icon: database
color: orange
inputs:
version:
description: Major Postgres version to install
required: true
default: 19
port:
description: The Postgres server port for Postgres
default: 55432
required: false
packages:
description: List of additional packages to install
required: false
start:
description: Whether or not to start Postgres after installing
default: true
encoding:
description: The encoding to use for databases in the cluster
required: false
locale:
description: The locale to use for databases in the cluster
required: false
runs:
using: composite
steps:
- name: Install ${{ inputs.version }}
shell: bash
run: |
set -e
case "$RUNNER_OS" in
Linux)
sudo apt-get update
sudo apt-get install -y postgresql-common ca-certificates build-essential pgxnclient ${{ inputs.packages }}
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -v ${{ inputs.version }} -i -p
sudo sed -i 's/#create_main_cluster = true/create_main_cluster = false/' /etc/postgresql-common/createcluster.conf
if [ "${{ inputs.start }}" == 'true' ]; then
sudo pg_createcluster --start ${{ inputs.version }} test -p ${{ inputs.port }} ${{ inputs.locale && format('--locale {0}', inputs.locale) }} ${{ inputs.encoding && format('--encoding {0}', inputs.encoding) }} -- -A trust
fi
printf '/usr/lib/postgresql/${{ inputs.version }}/bin\n' >> "$GITHUB_PATH"
printf 'PGPORT=${{ inputs.port }}\nPGUSER=postgres\nPG_CONFIG=/usr/lib/postgresql/${{ inputs.version }}/bin/pg_config' >> "$GITHUB_ENV"
;;
macOS)
export HOMEBREW_GITHUB_ACTIONS=1
export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_INSTALL_UPGRADE=1
brew install -y --quiet "postgresql@${{ inputs.version }}" pgxnclient ${{ inputs.packages }}
brew unlink --quiet "postgresql@${{ inputs.version }}"
brew link --quiet --overwrite "postgresql@${{ inputs.version }}"
export PGDATA="$RUNNER_TEMP/pgdata${{ inputs.version }}"
if [ "${{ inputs.start }}" == 'true' ]; then
initdb -U postgres ${{ inputs.locale && format('--locale {0}', inputs.locale) }} ${{ inputs.encoding && format('--encoding {0}', inputs.encoding) }}
printf 'port = ${{ inputs.port }}\n' >> "$PGDATA/postgresql.conf"
pg_ctl start
fi
printf 'PGPORT=${{ inputs.port }}\nPGUSER=postgres\nPG_CONFIG=%s/bin/pg_config\n' "$(brew --prefix)" >> "$GITHUB_ENV"
;;
Windows)
choco install sudo ${{ inputs.packages }}
# Chocolatey downloads the PostgreSQL installer from
# get.enterprisedb.com, which intermittently responds with HTTP 403
# and aborts the install. Retry a few times to absorb such transient
# download failures.
for attempt in 1 2 3; do
if choco install postgresql${{ inputs.version }} \
--ia "--enable-components server,commandlinetools --extract-only 1" \
--no-progress; then
break
fi
if [ "$attempt" -eq 3 ]; then
echo "::error::Failed to install PostgreSQL after $attempt attempts."
exit 1
fi
echo "::warning::choco install failed (attempt $attempt), retrying in 15s..."
sleep 15
done
pip install pgxnclient
PG_DIR="$PROGRAMFILES/PostgreSQL/${{ inputs.version }}"
export PGDATA="$RUNNER_TEMP/pgdata${{ inputs.version }}"
if [ "${{ inputs.start }}" == 'true' ]; then
"$PG_DIR/bin/initdb.exe" -U postgres ${{ inputs.locale && format('--locale {0}', inputs.locale) }} ${{ inputs.encoding && format('--encoding {0}', inputs.encoding) }}
printf 'port = ${{ inputs.port }}\n' >> "$PGDATA/postgresql.conf"
"$PG_DIR/bin/pg_ctl.exe" start
fi
printf '%s\n' "$PG_DIR/bin" >> $GITHUB_PATH
printf 'PGDATA=\nPGBIN=\nPGPASSWORD=\nPGPORT=${{ inputs.port }}\nPGUSER=postgres\nPG_CONFIG=%s/bin/pg_config.exe\n' "$PG_DIR" >> "$GITHUB_ENV"
;;
*)
printf '%s not supported\n' "$RUNNER_OS"
exit 1
;;
esac