Skip to content

Allow dynamic environment names #320

Open

Description

@fabn

Details

We're using this action to deploy to dynamic environments, e.g. https://feature-1234.example.com where feature-1234 is the environment name. We use a branch slug to create the env name or allow the user to enter his one via .deploy to some-env.

However I need to hack the action to allow these names by doing some github workflows magic, like:

      # Allow to use the custom env name if provided via command (parsed from comment)
      - name: Final Env Name
        id: env
        run: |
          name=${{ steps.custom-env.outputs.result }}

      - uses: github/branch-deploy@v9.9.1
        id: bot
        with:
          trigger: ".deploy"
          environment: ${{ steps.env.outputs.name }}
          # Don't restrict the list of environments to deploy to, to allow usage of free-name environments
          environment_targets: ${{ steps.env.outputs.name }},staging,canary

It would be very useful to accept a falsey value for environment_targets (or some wildcard chars, or a regex) to allow dynamic env names.

Another option would be to provide an input to skip the environment_targets validation for the action.

Thanks.

Activity

  1. added
    questionFurther information is requested or the issue is a question
    on Nov 12, 2024
  2. GrantBirki commented on Nov 13, 2024

    @GrantBirki
    Contributor

    @fabn thank you for this idea! I can certainly see how this could be useful. Would you be able to provide an example yaml snippet of how you might want this to look to satisfy your use case? An example showing your desired end state would be super helpful. Thank you! 🙏

  3. fabn commented on Nov 16, 2024

    @fabn
    ContributorAuthor

    Would you be able to provide an example yaml snippet of how you might want this to look to satisfy your use case?

    I guess something like this would be enough for me:

          - uses: github/branch-deploy@v9.9.1
            id: bot
            with:
              environment: ${{ steps.env.outputs.name }}
              # Don't restrict the list of environments to deploy to, to allow usage of free-name environments
              environment_targets: 'staging,production,dev-*' 
              # Or a regexp, of course you need to choose between targets and regexp, it's confusing to use both
              environment_regexp: 'dev-.*'
  4. GrantBirki commented on Dec 23, 2024

    @GrantBirki
    Contributor

    I think that this could be a great feature but I'm not 100% sure if it is something that I'll be able to allocate time towards in the near future. We are always open to PR contributions if you want to submit one. I think this could be useful for others as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested or the issue is a question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions