You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: auto-label PRs touching aidlc-rules/ with codebuild label (#158)
* feat: auto-label PRs using actions/labeler
Adds an auto-label job to the Pull Request Validation workflow using
actions/labeler v6.0.1. Labels are applied based on changed file paths
and removed when those files are no longer changed (sync-labels: true).
Works for fork PRs via pull_request_target — no checkout of fork code,
the action only reads file paths from the API.
Initial label rules:
- codebuild: aidlc-rules/**
- documentation: **/*.md, docs/**
- workflows: .github/**
* refactor: rename label to 'rules', refine labeler config
- Rename 'codebuild' label to 'rules' in codebuild.yml (conditions,
reminder text, and marker)
- Rename 'workflows' label to 'github' matching .github/**
- Scope 'documentation' label to *.md files NOT under aidlc-rules/
using all-globs-to-any-file with negation
* fix: add issues:write permission for auto-label job
Allows actions/labeler to create labels that don't yet exist in the
repository, preventing failures on first use of a new label rule.
* docs: update administrative guide for auto-labeling and rules label
- Rename all 'codebuild' label references to 'rules' (preserving
CodeBuild service/environment references)
- Add auto-label job to Pipeline 3 diagram and workflow reference
- Document label rules table (rules, documentation, github)
- Add actions/labeler to external actions table
- Add auto-label job to permissions table
- Add labeler.yml to repository tree diagram
---------
Co-authored-by: Scott Schreckengaust <345885+scottschreckengaust@users.noreply.github.com>
E -->|yes| F["label-cleanup\n(remove reminder comment)"]
121
122
F --> B
122
123
E -->|no| I["label-reminder\n(warning + PR comment)"]
@@ -135,9 +136,10 @@ flowchart TD
135
136
B --> E["fail-by-label\n(do-not-merge label)"]
136
137
A --> F["validate\n(conventional commit title)"]
137
138
A --> G["contributorStatement\n(acknowledgment in PR body)"]
139
+
A --> H["auto-label\n(actions/labeler)"]
138
140
```
139
141
140
-
`pull-request-lint.yml` runs on every PR targeting `main` and on merge queue checks. It enforces four gates: conventional commit PR titles, the contributor statement from the PR template, a configurable merge-halt mechanism, and a do-not-merge label check. The workflow uses `pull_request_target` (not `pull_request`) so it runs in the context of the base branch — this is safe because it never checks out PR code.
142
+
`pull-request-lint.yml` runs on every PR targeting `main` and on merge queue checks. It enforces four gates (conventional commit PR titles, the contributor statement from the PR template, a configurable merge-halt mechanism, and a do-not-merge label check) and automatically applies labels based on changed file paths. The workflow uses `pull_request_target` (not `pull_request`) so it runs in the context of the base branch — this is safe because it never checks out PR code and the `auto-label` job uses `actions/labeler` which only reads file paths from the API.
141
143
142
144
---
143
145
@@ -216,24 +218,24 @@ flowchart TD
216
218
217
219
**Purpose:** Runs an AWS CodeBuild project, downloads primary and secondary artifacts from S3, caches them in GitHub Actions cache, uploads them as workflow artifacts, and (when triggered from a `v*` tag) attaches them to the GitHub Release.
218
220
219
-
**PR label gate:** For `pull_request` events, the workflow only fires when files under `aidlc-rules/**` are changed (via `paths` filter) and the `build` job only runs when the `codebuild` label is present on the PR (via `contains(github.event.pull_request.labels.*.name, 'codebuild')`). The trigger includes `types: [opened, synchronize, reopened, labeled]` so that subsequent pushes to a labeled PR re-trigger the build automatically. `push`, `workflow_dispatch`, and tag events bypass the label check entirely.
221
+
**PR label gate:** For `pull_request` events, the workflow only fires when files under `aidlc-rules/**` are changed (via `paths` filter) and the `build` job only runs when the `rules` label is present on the PR (via `contains(github.event.pull_request.labels.*.name, 'rules')`). The `rules` label is applied automatically by the `auto-label` job in `pull-request-lint.yml` (see [Pull Request Validation Workflow](#pull-request-validation-workflow-pull-request-lintyml)). The trigger includes `types: [opened, synchronize, reopened, labeled]` so that subsequent pushes to a labeled PR re-trigger the build automatically. `push`, `workflow_dispatch`, and tag events bypass the label check entirely.
220
222
221
-
**Job: `label-reminder`** (PR only, no `codebuild` label)
223
+
**Job: `label-reminder`** (PR only, no `rules` label)
| 1 | Warn about missing codebuild label | Emits a `::warning::` annotation visible in the Actions summary |
227
+
| 1 | Warn about missing rules label| Emits a `::warning::` annotation visible in the Actions summary |
226
228
| 2 | Comment on PR | Posts a one-time PR comment (idempotent — skips if the reminder comment already exists) |
227
229
228
-
This job runs only for `pull_request` events where `aidlc-rules/**` changed but the `codebuild` label is absent. It alerts maintainers and reviewers that the evaluation pipeline was not triggered. The comment is posted once per PR using an HTML comment marker (`<!-- codebuild-label-reminder -->`) to avoid duplicates.
230
+
This job runs only for `pull_request` events where `aidlc-rules/**` changed but the `rules` label is absent. It alerts maintainers and reviewers that the evaluation pipeline was not triggered. The comment is posted once per PR using an HTML comment marker (`<!-- rules-label-reminder -->`) to avoid duplicates. In normal operation, the `auto-label` job in `pull-request-lint.yml` applies the `rules` label automatically, so this job serves as a fallback safety net.
| 1 | Remove label reminder comment | Finds and deletes the `label-reminder` PR comment (no-op if it doesn't exist) |
235
237
236
-
This job runs when the `codebuild` label is applied, immediately removing the reminder comment without waiting for the `codebuild` environment approval gate.
238
+
This job runs when the `rules` label is applied, immediately removing the reminder comment without waiting for the `codebuild` environment approval gate.
237
239
238
240
**Job: `build`**
239
241
@@ -351,6 +353,18 @@ Only runs for `pull_request` and `pull_request_target` events (not `merge_group`
Only runs for `pull_request_target` events. Uses [`actions/labeler`](https://github.com/actions/labeler) v6.0.1 to automatically apply and remove labels based on changed file paths. Label rules are defined in `.github/labeler.yml`:
|`github`|`.github/**`| Workflow, template, or config changes |
365
+
366
+
With `sync-labels: true`, labels are automatically removed when the matching files are no longer in the PR diff (e.g., after a rebase drops those changes). New label rules can be added by editing `.github/labeler.yml` — no workflow changes required.
Only runs for `pull_request` and `pull_request_target` events. Skipped for bot accounts (`dependabot[bot]`, `github-actions[bot]`, `github-actions`, `aidlc-workflows`). Verifies the PR body contains the contributor acknowledgment text from `.github/pull_request_template.md`:
@@ -361,6 +375,7 @@ Only runs for `pull_request` and `pull_request_target` events. Skipped for bot a
|`pull-request-lint.yml`|`auto-label`|`contents: read`, `issues: write`, `pull-requests: write`| Apply/remove labels based on changed file paths; `issues: write` allows creating labels that don't yet exist |
427
443
|`pull-request-lint.yml`|`get-pr-info`|`contents: read`, `pull-requests: read`| Read PR metadata and labels via API |
428
444
|`pull-request-lint.yml`|`check-merge-status`|`pull-requests: read`| Read PR state for merge gate checks |
429
445
|`pull-request-lint.yml`|`validate`|`pull-requests: read`| Read PR title for conventional commit validation |
@@ -441,7 +457,7 @@ Both `codebuild.yml` and `pull-request-lint.yml` follow a **deny-all-then-grant*
441
457
|**AWS authentication**| OIDC-based role assumption via `id-token: write` — no static credentials stored |
442
458
|**Least-privilege tokens**|`codebuild.yml` and `pull-request-lint.yml` explicitly deny all 16 permission scopes at workflow level, grant only required scopes at job level |
|**Label-gated CI**|`codebuild.yml` requires the `codebuild` label on PRs and only triggers for `aidlc-rules/**` changes, preventing unnecessary builds and environment approval prompts |
460
+
|**Label-gated CI**|`codebuild.yml` requires the `rules` label on PRs and only triggers for `aidlc-rules/**` changes, preventing unnecessary builds and environment approval prompts. The label is applied automatically by the `auto-label` job in `pull-request-lint.yml`|
445
461
|**Concurrency control**|`codebuild.yml` and `pull-request-lint.yml` cancel in-progress runs for the same branch |
446
462
|**Safe PR trigger**|`pull-request-lint.yml` uses `pull_request_target` but never checks out PR code — only inspects metadata (title, labels, body) |
447
463
|**Injection-safe inputs**| Zero `${{ }}` expression interpolation in `run:` blocks — all dynamic values (`github.ref_name`, `github.repository`, `env.*`, event inputs) passed via step-level `env:` or auto-exported workflow `env:` variables |
0 commit comments