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:
parent
5b0f08362a
commit
792069e9f3
1 changed files with 15 additions and 3 deletions
18
action.yml
18
action.yml
|
@ -12,9 +12,8 @@ runs:
|
||||||
- name: Get cache directory
|
- name: Get cache directory
|
||||||
id: cache-dir
|
id: cache-dir
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ runner.os }}" == "Linux" ]]; then
|
cache_dir=""
|
||||||
cache_dir="/var/cache/apt/archives/"
|
if [[ "${{ runner.os }}" == "macOS" ]]; then
|
||||||
elif [[ "${{ runner.os }}" == "macOS" ]]; then
|
|
||||||
cache_dir="$(brew --cache postgresql@${{ inputs.postgresql_version }})"
|
cache_dir="$(brew --cache postgresql@${{ inputs.postgresql_version }})"
|
||||||
elif [[ "${{ runner.os }}" == "Windows" ]]; then
|
elif [[ "${{ runner.os }}" == "Windows" ]]; then
|
||||||
cache_dir="~\AppData\Local\Temp\chocolatey"
|
cache_dir="~\AppData\Local\Temp\chocolatey"
|
||||||
|
@ -24,6 +23,8 @@ runs:
|
||||||
|
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
|
id: cache-postgresql
|
||||||
|
if: steps.cache-dir.outputs.cache_dir != ''
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.cache-dir.outputs.cache_dir }}
|
path: ${{ steps.cache-dir.outputs.cache_dir }}
|
||||||
key: ${{ runner.os }}-postgresql-${{ inputs.postgresql_version }}
|
key: ${{ runner.os }}-postgresql-${{ inputs.postgresql_version }}
|
||||||
|
@ -33,10 +34,21 @@ runs:
|
||||||
- run: |
|
- run: |
|
||||||
bash $GITHUB_ACTION_PATH/entrypoint.sh
|
bash $GITHUB_ACTION_PATH/entrypoint.sh
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: steps.cache-postgresql.outputs.cache-hit != 'true'
|
||||||
env:
|
env:
|
||||||
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
# 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
|
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
|
||||||
INPUT_POSTGRESQL_VERSION: ${{ inputs.postgresql_version }}
|
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:
|
branding:
|
||||||
icon: hard-drive
|
icon: hard-drive
|
||||||
color: white
|
color: white
|
||||||
|
|
Loading…
Add table
Reference in a new issue