{"id":30854437,"url":"https://github.com/prisma/create-prisma-postgres-database-action","last_synced_at":"2025-09-07T10:40:32.824Z","repository":{"id":305787090,"uuid":"1021496907","full_name":"prisma/create-prisma-postgres-database-action","owner":"prisma","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-23T08:03:26.000Z","size":270,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-28T13:46:45.139Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma.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,"zenodo":null}},"created_at":"2025-07-17T13:38:37.000Z","updated_at":"2025-08-01T17:39:40.000Z","dependencies_parsed_at":"2025-07-22T03:08:28.450Z","dependency_job_id":"1b7aa947-e7b8-4a51-a0ab-774f8ea1ac5c","html_url":"https://github.com/prisma/create-prisma-postgres-database-action","commit_stats":null,"previous_names":["prisma/create-prisma-postgres-database-action"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/prisma/create-prisma-postgres-database-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fcreate-prisma-postgres-database-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fcreate-prisma-postgres-database-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fcreate-prisma-postgres-database-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fcreate-prisma-postgres-database-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/create-prisma-postgres-database-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fcreate-prisma-postgres-database-action/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274026708,"owners_count":25209739,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-07T10:40:30.576Z","updated_at":"2025-09-07T10:40:32.814Z","avatar_url":"https://github.com/prisma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create Prisma Postgres Database Action\n\nA GitHub Action to create Prisma Postgres databases in your CI/CD workflows.\n\n## Usage\n\n### Basic Usage\n\n```yaml\n- name: Create Database\n  id: create\n  uses: prisma/create-prisma-postgres-database-action@v1\n  with:\n    service_token: ${{ secrets.PRISMA_POSTGRES_SERVICE_TOKEN }}\n    project_id: ${{ secrets.PRISMA_PROJECT_ID }}\n\n- name: Use Database\n  env:\n    DATABASE_URL: ${{ steps.create.outputs.database_url }}\n  run: |\n    echo \"Database ready: ${{ steps.create.outputs.database_name }}\"\n    # Use the DATABASE_URL in your application\n```\n\n### With Custom Database Name\n\n```yaml\n- name: Create Database\n  uses: prisma/create-prisma-postgres-database-action@v1\n  with:\n    service_token: ${{ secrets.PRISMA_POSTGRES_SERVICE_TOKEN }}\n    project_id: ${{ secrets.PRISMA_PROJECT_ID }}\n    database_name: \"my-test-db\"\n```\n\n### Complete Example to Provision Prisma Postgres when PR is opened and delete when PR is closed\n\n```yaml\nname: Prisma Postgres Database Lifecycle\non:\n  pull_request:\n    types: [opened, reopened, synchronize, closed]\n\njobs:\n  create-database:\n    name: Create Database\n    if: github.event.action != 'closed'\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Create Database\n        id: create\n        uses: prisma/create-prisma-postgres-database-action@v1\n        with:\n          service_token: ${{ secrets.PRISMA_POSTGRES_SERVICE_TOKEN }}\n          project_id: ${{ secrets.PRISMA_PROJECT_ID }}\n          database_name: \"pr-${{ github.event.pull_request.number }}\"\n\n      - name: Verify database creation\n        run: |\n          echo \"✅ Database created successfully!\"\n          echo \"Database ID: ${{ steps.create.outputs.database_id }}\"\n          echo \"Database Name: ${{ steps.create.outputs.database_name }}\"\n          echo \"Database URL is available in steps.create.outputs.database_url\"\n\n  cleanup-database:\n    name: Cleanup Database  \n    if: always() \u0026\u0026 github.event.action == 'closed'\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Delete Database\n        id: delete\n        uses: prisma/delete-prisma-postgres-database-action@v1\n        with:\n          service_token: ${{ secrets.PRISMA_POSTGRES_SERVICE_TOKEN }}\n          project_id: ${{ secrets.PRISMA_PROJECT_ID }}\n          database_name: \"pr-${{ github.event.pull_request.number }}\"\n\n      - name: Verify database deletion\n        run: |\n          if [ \"${{ steps.delete.outputs.deleted }}\" == \"true\" ]; then\n            echo \"✅ Database ${{ steps.delete.outputs.database_name }} was deleted\"\n          else\n            echo \"ℹ️ No database found to delete\"\n          fi\n```\n\n## Inputs\n\n| Input           | Description                   | Required | Default        |\n| --------------- | ----------------------------- | -------- | -------------- |\n| `service_token` | Prisma Postgres service token | ✅       |                |\n| `project_id`    | Prisma project ID             | ✅       |                |\n| `database_name` | Database name                 | ❌       | Auto-generated |\n| `region`        | Database region               | ❌       | `us-east-1`    |\n\n## Outputs\n\n| Output          | Description                             |\n| --------------- | --------------------------------------- |\n| `database_id`   | The ID of the created/existing database |\n| `database_name` | The name of the database                |\n| `database_url`  | The DATABASE_URL for the database       |\n\n## Setup\n\n### 1. Get Prisma Postgres Credentials\n\n1. Sign up for [Prisma Postgres](https://www.prisma.io/postgres)\n2. Generate a service token\n\n### 2. Create a Dedicated Project for CI\n\nTo avoid conflicts with your development databases, create a dedicated project specifically for CI workflows. Use the following curl command to create a new Prisma Postgres project:\n\n```bash\ncurl -X POST https://api.prisma.io/v1/projects \\\n  -H \"Authorization: Bearer $PRISMA_POSTGRES_SERVICE_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d \"{\\\"region\\\": \\\"us-east-1\\\", \\\"name\\\": \\\"$PROJECT_NAME\\\"}\"\n```\n\nNote the project ID from the response.\n\n### 3. Add Repository Secrets\n\nGo to your repository settings → Secrets and variables → Actions, and add:\n\n- `PRISMA_POSTGRES_SERVICE_TOKEN`: Your Prisma Postgres service token\n- `PRISMA_PROJECT_ID`: Your Prisma project ID\n\n### 4. Use in Your Workflow\n\nAdd the action to your workflow as shown in the examples above.\n\n## Database Naming\n\n**Auto-generated names:**\n\n- PR context: `pr_{pr_number}_{branch_name}`\n- Other contexts: `test_{run_number}`\n\n## Using with Different Tools\n\nThis action only provisions the database and provides a connection string. You can use it with any database tool:\n\n### With Prisma\n\n```yaml\n- name: Setup with Prisma\n  env:\n    DATABASE_URL: ${{ steps.provision.outputs.database_url }}\n  run: |\n    npx prisma generate\n    npx prisma db push\n```\n\n## Related Actions\n\n- [Delete Prisma Postgres Database Action](https://github.com/prisma/delete-prisma-postgres-database-action) - Delete Prisma Postgres database\n\n## Support\n\nFor issues and questions:\n\n- [GitHub Issues](https://github.com/prisma/create-prisma-postgres-database-action/issues)\n- [Prisma Postgres Documentation](https://www.prisma.io/docs/postgres)\n\n## License\n\nApache License - see [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fcreate-prisma-postgres-database-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fcreate-prisma-postgres-database-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fcreate-prisma-postgres-database-action/lists"}