0
0
Fork 0
mirror of https://github.com/tj-actions/install-postgresql.git synced 2024-12-20 01:18:18 +00:00

Add support for validating the postgresql version

This commit is contained in:
Tonye Jack 2023-09-12 10:41:29 -06:00
parent 5b0f08362a
commit 792069e9f3

View file

@ -12,9 +12,8 @@ runs:
- name: Get cache directory
id: cache-dir
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
cache_dir="/var/cache/apt/archives/"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
cache_dir=""
if [[ "${{ runner.os }}" == "macOS" ]]; then
cache_dir="$(brew --cache postgresql@${{ inputs.postgresql_version }})"
elif [[ "${{ runner.os }}" == "Windows" ]]; then
cache_dir="~\AppData\Local\Temp\chocolatey"
@ -24,6 +23,8 @@ runs:
- name: Cache
uses: actions/cache@v3
id: cache-postgresql
if: steps.cache-dir.outputs.cache_dir != ''
with:
path: ${{ steps.cache-dir.outputs.cache_dir }}
key: ${{ runner.os }}-postgresql-${{ inputs.postgresql_version }}
@ -33,10 +34,21 @@ runs:
- run: |
bash $GITHUB_ACTION_PATH/entrypoint.sh
shell: bash
if: steps.cache-postgresql.outputs.cache-hit != 'true'
env:
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_POSTGRESQL_VERSION: ${{ inputs.postgresql_version }}
- name: Verify PostgreSQL
run: |
# Check the postgresql version
POSTGRESQL_VERSION=$(psql --version | awk '{print $3}')
if [[ "$POSTGRESQL_VERSION" != "${{ inputs.postgresql_version }}."* ]]; then
echo "PostgreSQL version $POSTGRESQL_VERSION does not match the expected version ${{ inputs.postgresql_version }}.*"
exit 1
fi
shell: bash
branding:
icon: hard-drive
color: white