From fcd2d09e4bc4a884526f3b877fc085bc9d30673a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 11 Sep 2023 19:32:39 -0600 Subject: [PATCH] feat: add support for caching --- action.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/action.yml b/action.yml index 3de8805..1b79464 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,27 @@ inputs: runs: using: 'composite' 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: | bash $GITHUB_ACTION_PATH/entrypoint.sh shell: bash