github / github/branch-deploy

Prefixing environments for mono-repo setup

Đang mở
#168 11 bình luận 9 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
TypeScript
Star
576
Fork
74
Merge trung bình
11 giờ 7 phút
Pull request đã merge (30 ngày)
1

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
github-actions, terraform, typescript
Lĩnh vực
ci-cd, devops
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.