diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8374b2e..0aaec1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,15 @@ on: - main jobs: + shellcheck: + name: Run shellcheck + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - name: shellcheck + uses: reviewdog/action-shellcheck@v1.19 test: runs-on: ubuntu-latest name: Test postgres-restore diff --git a/action.yml b/action.yml index 1e3f6b1..95e6f6a 100644 --- a/action.yml +++ b/action.yml @@ -20,9 +20,15 @@ runs: using: 'composite' steps: - run: | - mkdir -p $(dirname "${{ inputs.path }}") - pg_dump ${{ inputs.options }} -d "${{ inputs.database_url }}" > "${{ inputs.path }}" + bash $GITHUB_ACTION_PATH/entrypoint.sh shell: bash + 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 }} + INPUT_PATH: ${{ inputs.path }} + INPUT_DATABASE_URL: ${{ inputs.database_url }} + INPUT_OPTIONS: ${{ inputs.options }} branding: icon: hard-drive color: white diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index 5b2371c..a8c7df5 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,3 +1,20 @@ #!/usr/bin/env bash set -euo pipefail + +echo "::group::pg-dump" + +echo "Creating the output directory..." + +mkdir -p $(dirname "$INPUT_PATH") + +echo "Created the output directory" + +echo "Running pg_dump..." + +# shellcheck disable=SC2086 +pg_dump $INPUT_OPTIONS -d "$INPUT_DATABASE_URL" > "$INPUT_PATH" + +echo "Complete" + +echo "::endgroup::" \ No newline at end of file