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

43 lines
1.5 KiB
YAML

name: install-postgresql
description: Install PostgreSQL on the GitHub actions runner and verify the installation.
author: tj-actions
inputs:
postgresql_version:
description: 'Version of PostgreSQL. e.g 15'
required: true
runs:
using: 'composite'
steps:
- name: Get cache directory
id: cache-dir
run: |
set -x
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="~\AppData\Local\Temp\chocolatey\postgresql-${{ inputs.postgresql_version }}"
fi
echo "cache_dir=$cache_dir" >> "$GITHUB_OUTPUT"
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
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 }}
branding:
icon: hard-drive
color: white