mirror of
https://github.com/tj-actions/pg-dump.git
synced 2024-12-20 01:18:49 +00:00
Updated action
This commit is contained in:
parent
a943f34469
commit
b325dee489
1 changed files with 3 additions and 60 deletions
|
@ -14,67 +14,10 @@ else
|
|||
echo "The output directory already exists"
|
||||
fi
|
||||
|
||||
if [[ -n "$INPUT_POSTGRESQL_VERSION" ]]; then
|
||||
echo "Verifying version"
|
||||
echo "Running pg_dump..."
|
||||
|
||||
# Check if the input is an integer
|
||||
if ! [[ "$INPUT_POSTGRESQL_VERSION" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: $INPUT_POSTGRESQL_VERSION is not a valid integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the input is between 10 and 15 (inclusive)
|
||||
if (( INPUT_POSTGRESQL_VERSION < 10 || INPUT_POSTGRESQL_VERSION > 15 )); then
|
||||
echo "Error: $INPUT_POSTGRESQL_VERSION is not between 10 and 15 (inclusive)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Validated postgresql version: $INPUT_POSTGRESQL_VERSION"
|
||||
|
||||
echo "Installing postgresql..."
|
||||
|
||||
if [[ "$(uname -s)" == "Linux" ]]; then
|
||||
# Create the file repository configuration:
|
||||
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
# Import the repository signing key:
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
# Update the package lists:
|
||||
sudo apt-get update
|
||||
|
||||
# Install PostgreSQL
|
||||
sudo apt-get install -y "postgresql-$INPUT_POSTGRESQL_VERSION"
|
||||
elif [[ "$(uname -s)" == "NT"* ]]; then
|
||||
choco install postgresql --version="$INPUT_POSTGRESQL_VERSION" -y
|
||||
elif [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
brew update
|
||||
brew install "postgresql@$INPUT_POSTGRESQL_VERSION"
|
||||
else
|
||||
echo "Unsupported OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installed postgresql"
|
||||
|
||||
echo "Running pg_dump..."
|
||||
|
||||
# Verify installation by running pg_dump directly
|
||||
if [[ "$(uname -s)" == "NT"* ]]; then
|
||||
"/Program Files/PostgreSQL/$INPUT_POSTGRESQL_VERSION/bin/pg_dump" --version
|
||||
# shellcheck disable=SC2086
|
||||
"/Program Files/PostgreSQL/$INPUT_POSTGRESQL_VERSION/bin/pg_dump" $INPUT_OPTIONS -d "$INPUT_DATABASE_URL" > "$INPUT_PATH"
|
||||
else
|
||||
"/usr/lib/postgresql/$INPUT_POSTGRESQL_VERSION/bin/pg_dump" --version
|
||||
# shellcheck disable=SC2086
|
||||
"/usr/lib/postgresql/$INPUT_POSTGRESQL_VERSION/bin/pg_dump" $INPUT_OPTIONS -d "$INPUT_DATABASE_URL" > "$INPUT_PATH"
|
||||
fi
|
||||
else
|
||||
echo "Running pg_dump..."
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
pg_dump $INPUT_OPTIONS -d "$INPUT_DATABASE_URL" > "$INPUT_PATH"
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
pg_dump $INPUT_OPTIONS -d "$INPUT_DATABASE_URL" > "$INPUT_PATH"
|
||||
|
||||
echo "Complete"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue