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

feat: add support for caching

This commit is contained in:
Tonye Jack 2023-09-11 19:32:39 -06:00
parent 39233dcfab
commit fcd2d09e4b

View file

@ -9,6 +9,27 @@ inputs:
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
- name: Get cache directory
id: cache-dir
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
cache_dir=$(apt-cache policy postgresql-${{ inputs.postgresql_version }} | awk '/Filename/ {print $2}')
elif [[ "${{ runner.os }}" == "macOS" ]]; then
cache_dir=$(brew --cache postgresql@${{ inputs.postgresql_version }})
elif [[ "${{ runner.os }}" == "Windows" ]]; then
cache_dir=$(choco search postgresql${{ inputs.postgresql_version }} --exact --limit-output | grep "^postgresql " | awk '{print $NF}')
fi
echo "::set-output name=cache_dir::$cache_dir"
shell: bash
- name: Cache
uses: actions/cache@v3
with:
path: ${{ steps.cache-dir.outputs.cache_dir }}
key: ${{ runner.os }}-postgresql-${{ inputs.postgresql_version }}
restore-keys: |
${{ runner.os }}-postgresql-
- run: | - run: |
bash $GITHUB_ACTION_PATH/entrypoint.sh bash $GITHUB_ACTION_PATH/entrypoint.sh
shell: bash shell: bash