denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[KV Feedback]: Enable more environments than "Prod" via deployctl #732

Closed csvn closed 1 month ago

csvn commented 1 month ago

🔍

Type of feedback

Feature request

Description

Hello! We have a cloud service used for B2B customers where we have several projects where we need more than just "Prod" (main) and "Preview" (branch). This is because we have need for developer testing environments as well as a specialized environment used by our sales department. It looks something like this:

Environment Deployment Env variables / KV Description
Production main prod Primary site. Used by customers
Demo main (schedule: Saturdays@03.00) prod Used by the sales department
Dev main dev Used to mirror prod, but with non-production data
QA main stage Here we can point KV to a local path for SQLite usage to always start with the same data (?)
Preview [branch] dev Created for every PR to preview changes

Right now, we must create three projects to set a domain, environment variables and a separate KV for each, but this feels very unnecessary as the deployments we create (files being uploaded) are the same and duplicated many times. For this feature to work, it would be necessary to register a domain for each "environment" and as well as environment variables and which KV instance to use (or share).

# Rough structure of data to configure in `dash.deno.com`:
environments:
  prod:
    name: Production
    kv: prod
    variables:
      ANALYTICS: true
      FLAG_FOO_ENABLED: false
    domains:
      - example.com
  dev:
    name: Development
    kv: dev
    variables:
      ANALYTICS: false
      FLAG_FOO_ENABLED: true
    domains:
      - dev.example.com
# ...

Possible solution

It's possible to add a new parameter to deployctl. Instead of passing --prod, it's possible to pass --env=prod or --env-name=dev, or via the action. Passing a comma separated list would deploy the same files to multiple environments, thus being able to reduce deployment files multiple times with different env config:

jobs:
  deploy:
    if: github.ref_name == github.event.repository.default_branch
    # ..
    - uses: denoland/deployctl@v1
      with:
        project: ${{ vars.DENO_PROJECT_ID }}
        entrypoint: ./main.ts
        environment: prod,dev,qa 

The deployctl instance would then use the variables/kv-instance/domain configured for each environment name when creating the deployment.

Additional context

I feel like doing this would help a lot with consolidating all the information in the Deno Deploy Dashboard. Right now we are using 6 projects for 3 Github repositories. So to view logs/analytics/KV would mean constantly swapping around between different projects. It also makes it more complicated to share KV data in a good manner.

csvn commented 1 month ago

Oops, created a KV feature request instead of a deploy one, closing this one in favor of #733.