github / github/branch-deploy

Prefixing environments for mono-repo setup

Abierto
#168 11 comentarios 9 reacciones 0 asignados Ver en GitHub
question
Lenguaje dominante
TypeScript
Estrellas
576
Forks
74
Merge medio
11 h 7 min
PR fusionados (30 d)
1

Descripción

### Details

I handle infrastructure code (Terraform) in a mono-repo, which necessitates the deployment of numerous projects across various environments from a single repository.

I managed to implement a separate branch-deployment gate for each project using distinct triggers:

```yaml
trigger:
if: |
github.event.issue.pull_request
runs-on: ubuntu-latest
steps:
- name: Gate branch deployment
id: branch-deploy
uses: github/branch-deploy@v6.0.0
with:
trigger: .deploy ${{ inputs.project_name }}
noop_trigger: plan
```

The above configuration produces the following IssueOps interface:

```
.deploy foo dev/staging/prod
.deploy foo plan dev/staging/prod

.deploy bar dev/staging/prod
.deploy bar plan dev/staging/prod
```

However, given multiple projects, specified environments, i.e., `dev/staging/prod`, are "shared" (from the `branch-deploy` action's perspective), which implies that whenever I deploy to project `foo`, corresponding Github environments are being locked and altered with deployment status, preventing me against deploying to the `boo` project from other pull requests.

Consequently, in a mono-repo setup, one must distinguish Github environments by project, e.g., using a prefix: `foo-dev` vs. `bar-dev`, `foo-prod` vs. `bar-prod`, etc.

That is possible to implement by a combination of `environment` and `environment_targets` input variables:

```yaml
environment: foo-dev
environment_targets: foo-dev,foo-staging,foo-prod
```

However, with the current design of the `branch-deploy` action, the IssueOps interface would look like this:

```
.deploy foo foo-dev
.deploy bar bar-dev
```

... which seems inconvenient and unreadable as one has to repeat the project name twice.

I wonder if we could introduce an additional parameter, e.g., `environment_prefix`, that would alter the behavior of the `branch-deploy` action internally so that the action, given an environment `dev` (from issue comment), prefixes it internally with `environment_prefix` and only the prefixed Github environment is used for further processing. In other words, it would be great to somehow separate input environments from Github environments.

```yaml
environment: dev
environment_targets: dev,staging,prod
environment_prefix: foo
```

That would be a significant enabler towards adopting the action into existing mono-repo configurations.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start by tracing how the action processes the environment and environment_targets inputs from the IssueOps comment through GitHub environment handling. Define how environment_prefix should transform the internal environment names while keeping comments such as `.deploy foo dev` readable, then verify that prefixed environments are used consistently for deployment status and locking.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
github-actions, terraform, typescript
Área
ci-cd, devops
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.