Skip to content

Commit

Permalink
Implement PostGIS install for Linux, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Oct 30, 2022
1 parent b537920 commit 56333f4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# setup-postgres

This action sets up a PostgreSQL server for the rest of the job. Here are some
key features:
This action sets up a PostgreSQL server with PostGIS extension. The code is based on the [ikalnytskyi/action-setup-postgres](https://github.com/ikalnytskyi/action-setup-postgres) action.

* Runs on Linux, macOS and Windows runners.
* Adds PostgreSQL [binaries][1] (e.g. `psql`) to `PATH`.
* Uses PostgreSQL installed in [GitHub Actions Virtual Environments][2].
* Installs the correct version of PostGIS and runs `CREATE EXTENSION postgis` in the new database.
* [Easy to check][3] that IT DOES NOT contain malicious code.

[1]: https://www.postgresql.org/docs/current/reference-client.html
Expand All @@ -14,27 +14,29 @@ key features:

## Usage

| Key | Value |
|----------|-----------------------------------------------------|
| URI | `postgresql://postgres:postgres@localhost/postgres` |
| Host | `localhost` |
| Port | `5432` |
| Username | `postgres` |
| Password | `postgres` |
| Database | `postgres` |
| Key | Value |
|------------|-----------------------------------------------------|
| URI | `postgresql://postgres:postgres@localhost/postgres` |
| Host | `localhost` |
| Port | `5432` |
| Username | `postgres` |
| Password | `postgres` |
| Database | `postgres` |
| Rights | `--createdb` |
| Cached-dir | `downloads` |

#### Basic

```yaml
steps:
- uses: ikalnytskyi/action-setup-postgres@v3
- uses: nyurik/action-setup-postgis@main
```
#### Advanced
```yaml
steps:
- uses: ikalnytskyi/action-setup-postgres@v3
- uses: nyurik/action-setup-postgis@main
with:
username: ci
password: sw0rdfish
Expand Down
21 changes: 19 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Setup PostgreSQL for Linux/macOS/Windows
name: Setup PostgreSQL and PostGIS for Linux/macOS/Windows
author: Yuri Astrakhan
description: Setup PostgreSQL server and install PostGIS extension.
branding:
Expand Down Expand Up @@ -38,7 +38,24 @@ runs:
steps:
- name: Install PostGIS (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install postgis
run: |
# Detect installed PostgreSQL version
PG_VERSION=$(apt list --installed | grep -E 'postgresql-[0-9.]+' | sed -rn 's/.*postgresql-([0-9.]+).*/\1/p')
[[ "$PG_VERSION" =~ ^[0-9.]+$ ]] || (echo "Failed to detect Postgres version" && exit 1)
echo "Detected PostgreSQL version: $PG_VERSION"
# Install PostGIS
REPO_URL="https://apt.postgresql.org/pub/repos/apt/"
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /usr/share/keyrings/postgresql.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] $REPO_URL $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list >/dev/null
sudo apt update
sudo apt-get install postgresql-$PG_VERSION-postgis-3
# sudo apt install curl ca-certificates gnupg
# curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
# sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# sudo apt update
# sudo apt-get install postgis
shell: bash

- name: Install PostGIS (Mac)
Expand Down

0 comments on commit 56333f4

Please sign in to comment.