github / github/branch-deploy

Prefixing environments for mono-repo setup

オープン
#168 コメント 11 件 リアクション 9 件 担当者 0 名 GitHub で見る
question
主要言語
TypeScript
スター
576
フォーク
74
平均マージ
11時間 7分
マージ済み PR(30日)
1

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
github-actions, terraform, typescript
領域
ci-cd, devops
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。