{"id":15651431,"url":"https://github.com/ikalnytskyi/action-setup-postgres","last_synced_at":"2025-04-05T06:02:09.840Z","repository":{"id":41464335,"uuid":"430889572","full_name":"ikalnytskyi/action-setup-postgres","owner":"ikalnytskyi","description":"Setup a PostgreSQL for Linux, macOS and Windows runner machines.","archived":false,"fork":false,"pushed_at":"2024-10-24T19:47:44.000Z","size":69,"stargazers_count":43,"open_issues_count":4,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T05:01:44.686Z","etag":null,"topics":["actions","github-actions","postgres","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ikalnytskyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"ikalnytskyi","custom":"https://send.monobank.ua/2GWDRDwGZ8"}},"created_at":"2021-11-22T22:54:58.000Z","updated_at":"2025-03-21T08:46:10.000Z","dependencies_parsed_at":"2023-12-29T22:17:08.861Z","dependency_job_id":"b7796ff7-f985-4938-9782-0a3a48fda268","html_url":"https://github.com/ikalnytskyi/action-setup-postgres","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Faction-setup-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Faction-setup-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Faction-setup-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Faction-setup-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikalnytskyi","download_url":"https://codeload.github.com/ikalnytskyi/action-setup-postgres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294514,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","github-actions","postgres","postgresql"],"created_at":"2024-10-03T12:38:23.276Z","updated_at":"2025-04-05T06:02:09.822Z","avatar_url":"https://github.com/ikalnytskyi.png","language":"Python","funding_links":["https://ko-fi.com/ikalnytskyi","https://send.monobank.ua/2GWDRDwGZ8"],"categories":[],"sub_categories":[],"readme":"# setup-postgres\n\n[![CI build](https://img.shields.io/github/actions/workflow/status/ikalnytskyi/action-setup-postgres/ci.yml?style=for-the-badge\u0026logo=github\u0026label=Tests)](https://github.com/ikalnytskyi/action-setup-postgres/actions)\n[![GitHub](https://img.shields.io/badge/github-ikalnytskyi/action--setup--postgres-3795BD?logo=github\u0026style=for-the-badge)](https://github.com/ikalnytskyi/action-setup-postgres)\n[![Marketplace](https://img.shields.io/badge/market-setup--postgres-4E31AA?logo=github\u0026style=for-the-badge)](https://github.com/marketplace/actions/setup-postgresql-for-linux-macos-windows)\n\nThis action sets up a PostgreSQL server for the rest of the job. Here are some\nkey features:\n\n* Runs on Linux, macOS and Windows action runners.\n* PostgreSQL version can be parametrized.\n* Adds PostgreSQL [client applications][1] to `PATH`.\n* Supports SSL on-demand.\n* Easy [to verify][2] that it DOES NOT contain malicious code.\n\n[1]: https://www.postgresql.org/docs/current/reference-client.html\n[2]: action.yml\n\n#### Inputs\n\n| Key              | Value                                                                              | Default     |\n|------------------|------------------------------------------------------------------------------------|-------------|\n| username         | The username of the user to setup.                                                 | `postgres`  |\n| password         | The password of the user to setup.                                                 | `postgres`  |\n| database         | The database name to setup and grant permissions to created user.                  | `postgres`  |\n| port             | The server port to listen on.                                                      | `5432`      |\n| postgres-version | The PostgreSQL major version to install. Supported values: \"14\", \"15\", \"16\", \"17\". | `17`        |\n\n#### Outputs\n\n| Key              | Description                                      | Example                                             |\n|------------------|--------------------------------------------------|-----------------------------------------------------|\n| connection-uri   | The connection URI to connect to PostgreSQL.     | `postgresql://postgres:postgres@localhost/postgres` |\n| service-name     | The service name with connection parameters.     | `postgres`                                          |\n| certificate-path | The path to the server certificate if SSL is on. | `/home/runner/work/_temp/pgdata/server.crt`         |\n\n#### User permissions\n\n| Key         | Value |\n|-------------|-------|\n| usesuper    | true  |\n| usecreatedb | true  |\n\n\n## Usage\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e In order to connect to a PostgreSQL server, either use connection parameters\n\u003e directly (see [basic] example), or, preferably, obtain a connection URI from\n\u003e the `connection-uri` output (see [recommended] example).\n\u003e\n\u003e [basic]: #basic\n\u003e [recommended]: #recommended\n\n\u003e [!TIP]\n\u003e\n\u003e For `libpq`-based applications, such as PostgreSQL client applications, set\n\u003e the `PGSERVICE=postgres` environment variable to automatically use the\n\u003e correct connection parameters (see [example]). The `postgres` value\n\u003e corresponds to the service name from the `service-name` output.\n\u003e\n\u003e [example]: #how-do-i-create-a-new-database-with-a-new-user\n\n#### Basic\n\n```yaml\nsteps:\n  - uses: ikalnytskyi/action-setup-postgres@v7\n\n  - run: psql postgresql://postgres:postgres@localhost:5432/postgres -c \"SELECT 1\"\n  - run: psql service=postgres -c \"SELECT 1\"\n  - run: psql -c \"SELECT 1\"\n    env:\n      PGSERVICE: postgres\n```\n\n#### Recommended\n\n```yaml\nsteps:\n  - uses: ikalnytskyi/action-setup-postgres@v7\n    id: postgres\n\n  - run: psql ${{ steps.postgres.outputs.connection-uri }} -c \"SELECT 1\"\n  - run: psql service=${{ steps.postgres.outputs.service-name }} -c \"SELECT 1\"\n  - run: psql -c \"SELECT 1\"\n    env:\n      PGSERVICE: ${{ steps.postgres.outputs.service-name }}\n```\n\n#### Parametrized\n\n```yaml\nsteps:\n  - uses: ikalnytskyi/action-setup-postgres@v7\n    with:\n      username: ci\n      password: sw0rdfish\n      database: test\n      port: 34837\n      postgres-version: \"14\"\n      ssl: true\n    id: postgres\n\n  - run: psql ${{ steps.postgres.outputs.connection-uri }} -c \"SELECT 1\"\n  - run: psql service=${{ steps.postgres.outputs.service-name }} -c \"SELECT 1\"\n  - run: psql -c \"SELECT 1\"\n    env:\n      PGSERVICE: ${{ steps.postgres.outputs.service-name }}\n```\n\n## FAQ\n\n#### How do I create a new database with a new user?\n\n```yaml\nsteps:\n  - uses: ikalnytskyi/action-setup-postgres@v7\n    id: postgres\n\n  - env:\n      PGSERVICE: \"${{ steps.postgres.outputs.service-name }}\"\n    run: |\n      createuser myuser\n      createdb --owner myuser mydatabase\n      psql -c \"ALTER USER myuser WITH PASSWORD 'mypassword'\"\n```\n\n## Rationale\n\nAt the time of developing there were no GitHub Actions on the marketplace to\nsetup a PostgreSQL server on Linux, Windows and macOS action runners. Most\nsolutions suggest using Docker which is not available on macOS and Windows\nrunners.\n\n## License\n\nThe scripts and documentation in this project are released under the\n[MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikalnytskyi%2Faction-setup-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikalnytskyi%2Faction-setup-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikalnytskyi%2Faction-setup-postgres/lists"}