diff --git a/action.yml b/action.yml index 3541e6c..ee7bb84 100644 --- a/action.yml +++ b/action.yml @@ -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_ 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