Non-deployment Environment Jobs

Currently environments assume that there’s a deploy happening. This causes friction with PRs that use env secrets but don’t actually “deploy” but instead are doing some sort of diff or non-deployment preview operation. This also included the “approvals” feature which requires approvals even when an environment is not actually being used to deploy anything.

It’d be great to make a job as a non-deploy job, and exclude these jobs from both deployment notifications and approvals.

1 Like

Thanks for the feedback. Environments are always tied to deployments as deployments act like “activity log” for an environment showing visibility on everything that’s happening with environments.

We understand there are some situations where deployment isn’t a think. We are considering transient environments that creates and delete deployments when a pull request is closed for example.

Thanks for the feedback and patience while we improve our product!

I was just trying to make the same work, Im currently going to trigger on PR close as delete environment or set deployment to inactive. It would great to have this be native.

I think there are 2 separate requests tho:

  • OP request is to be able to access the secrets no an environment without it being considered a deployment.
  • What you suggest @yaananth and what Im currently trying to do which is ephemeral environments for PRs.

Both would be great additions.

Forgot to add example code:

name: Development PR Cleanup

on:
  pull_request:
    branches:
      - main
    types:
      - closed

jobs:
  deployment-remove:
    runs-on: ubuntu-latest
    concurrency: ${{ github.event.pull_request.number }}
    steps:
      - name: Remove environment and deployment
        uses: actions/github-script@v5
        with:
          script: |
            const environment = "pr-${{ github.event.pull_request.number }}"

            github.rest.repos.deleteAnEnvironment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              environment_name: environment,
            });