Setup PostgreSQL and PostGIS for Linux/macOS/Windows
ActionsTags
(2)Tip
PostgreSQL installation is done by the ikalnytskyi/action-setup-postgres action.  All parameters are passed as is to the original action, with the addition of the cached-dir parameter to specify where to download and cache PostGIS binaries. See the original documentation for more details.
- Runs on all Linux, macOS and Windows GitHub runners
 - Installs the correct version of PostGIS and runs 
CREATE EXTENSION postgisin the new database.- Linux version is installed from the PostGIS apt repository.
 - Windows version is installed from the OSGeo.
 - MacOS version is installed using Homebrew package.
 
 
See also action-setup-nginx to configure NGINX service.
steps:
  - uses: nyurik/action-setup-postgis@v2
    id: postgres
  - name: Test PostGIS is installed
    run: psql -v ON_ERROR_STOP=1 -c 'SELECT PostGIS_Full_Version();' "$CONNECTION_STR"
    env:
      CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}| Key | Value | Default | 
|---|---|---|
| username | The username of the user to setup. | postgres | 
| password | The password of the user to setup. | postgres | 
| database | The database name to setup and grant permissions to created user. | postgres | 
| port | The server port to listen on. | 5432 | 
| postgres-version | The PostgreSQL version to install. | 17 | 
| postgis_version | (Windows only) The PostGIS version to installed. | By default (empty), will use the latest. See available versions here. If set, must use the entire version string like 3.3.3 | 
| cached-dir | Where should the temporary downloads be placed. Used to download and cache PostGIS binary. | downloads | 
| Key | Description | Example | 
|---|---|---|
| connection-uri | The connection URI to connect to PostgreSQL. | postgresql://postgres:postgres@localhost/postgres | 
| service-name | The service name with connection parameters. | postgres | 
| Key | Value | 
|---|---|
| usesuper | true | 
| usecreatedb | true | 
The scripts and documentation in this project are released under the MIT License.
Setup PostgreSQL and PostGIS for Linux/macOS/Windows is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.