Skip to content

Commit

Permalink
update postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
aqni committed Apr 28, 2024
1 parent 7ad8992 commit 627e344
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 153 deletions.
30 changes: 15 additions & 15 deletions .github/actions/dbRunner/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,18 @@ runs:

- if: inputs.DB-name=='PostgreSQL'
name: Run DB
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/postgresql.sh"
"${GITHUB_WORKSPACE}/.github/scripts/dataSources/postgresql.sh" 5432 5433 5434
elif [ "$RUNNER_OS" == "Windows" ]; then
chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/postgresql_windows.sh"
"${GITHUB_WORKSPACE}/.github/scripts/dataSources/postgresql_windows.sh" 5432 5433 5434
elif [ "$RUNNER_OS" == "macOS" ]; then
chmod +x "${GITHUB_WORKSPACE}/.github/scripts/dataSources/postgresql_macos.sh"
"${GITHUB_WORKSPACE}/.github/scripts/dataSources/postgresql_macos.sh" 5432 5433 5434
else
echo "$RUNNER_OS is not supported"
exit 1
fi
uses: ./.github/actions/service/postgresql
with:
stop: false
clean: false
start: true
ports: 5432 5433 5434

- if: inputs.DB-name=='PostgreSQL'
name: Modify IGinX Config
uses: ./.github/actions/edit
with:
paths: conf/config.properties
statements: |
s/storageEngineList=127.0.0.1#6667/#storageEngineList=127.0.0.1#6667/g
s/#storageEngineList=127.0.0.1#5432/storageEngineList=127.0.0.1#5432/g
67 changes: 67 additions & 0 deletions .github/actions/service/postgresql/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "postgresql"
description: "stop, clean and start postgresql in order"
inputs:
stop:
description: "whether to stop"
required: true
clean:
description: "whether to clean"
required: true
start:
description: "whether to start"
required: true
username:
description: The username of the user to setup.
default: postgres
required: false
password:
description: The password of the user to setup.
default: postgres
required: false
ports:
description: The server port to listen on.
default: "5432"
required: false

runs:
using: "composite"
steps:
- if: fromJSON(inputs.stop) || fromJSON(inputs.clean)
name: unimplemented
shell: bash
run: exit 1

- if: fromJSON(inputs.start)
name: Create postgresql Work Directory
shell: bash
working-directory: ${{ github.action_path }}
run: |
for port in ${{ inputs.ports }}; do
mkdir -p $port
done
- if: fromJSON(inputs.start)
name: Start postgresql
shell: bash
working-directory: ${{ github.action_path }}
run: |
for port in ${{ inputs.ports }}; do
PGDATA=${port}
PWFILE=${port}.pgpass
PGCONF=${PGDATA}/postgresql.conf
echo '${{ inputs.password }}' > "${PWFILE}"
initdb \
--pgdata="${PGDATA}" \
--username="${{ inputs.username }}" \
--pwfile="${PWFILE}" \
--auth="trust" \
--no-instructions
echo "port = ${port}" >> "${PGCONF}"
echo "unix_socket_directories = ''" >> "${PGCONF}"
echo "fsync = off" >> "${PGCONF}"
pg_ctl start --pgdata="${PGDATA}"
done
32 changes: 16 additions & 16 deletions .github/actions/setup/postgresql/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ description: "setup postgresql"
runs:
using: "composite"
steps:
- if: runner.os != 'Linux'
id: base
name: Initialize Setup Configuration
uses: ./.github/actions/setup/tool
with:
tool: postgresql
version: 15.6-1
- if: runner.os == 'Linux'
name: Add hosted postgresql bin to PATH
shell: bash
run: echo "$(pg_config --bindir)" >> $GITHUB_PATH

- if: runner.os == 'Windows'
name: Add hosted postgresql bin to PATH
shell: bash
run: echo "$PGBIN" >> $GITHUB_PATH

- if: runner.os != 'Linux'
- if: runner.os == 'macOS'
name: Restore postgresql Cache
id: restore
uses: actions/cache/restore@v3
with:
path: ${{ steps.base.outputs.cache-path }}
key: ${{ steps.base.outputs.cache-key }}

- if: runner.os != 'Linux'
- if: runner.os == 'macOS'
name: Setup postgresql into Runner Tool Cache
uses: pbrisbin/setup-tool-action@v2
with:
name: postgresql
version: 15.6-1
url: "https://get.enterprisedb.com/{name}/{name}-{version}-{os}-binaries.zip"
url: "https://get.enterprisedb.com/{name}/{name}-{version}-osx-binaries.{ext}"
subdir: "pgsql"
ext: "zip"
os-darwin: osx
os-win32: windows-x64

- if: runner.os != 'Linux'
name: Add influxdb HOME to ENV
- if: runner.os == 'macOS'
name: Add postgresql bin to PATH
shell: bash
working-directory: ${{ steps.base.outputs.tool-path }}
run: echo "PGHOME=$PWD" >> $GITHUB_ENV
run: echo "$PWD/bin" >> $GITHUB_PATH

- if: runner.os != 'Linux' && steps.restore.outputs.cache-hit != 'true'
- if: runner.os == 'macOS' && steps.restore.outputs.cache-hit != 'true'
name: Save postgresql Cache
uses: actions/cache/save@v3
with:
Expand Down
18 changes: 0 additions & 18 deletions .github/scripts/dataSources/postgresql.sh

This file was deleted.

55 changes: 0 additions & 55 deletions .github/scripts/dataSources/postgresql_macos.sh

This file was deleted.

49 changes: 0 additions & 49 deletions .github/scripts/dataSources/postgresql_windows.sh

This file was deleted.

0 comments on commit 627e344

Please sign in to comment.