Skip to content

Commit 58d341f

Browse files
authored
Add GitHub automation tools and custom structure templates (#62)
### Issue Closes #61 - Enhance STRUCT with additional contrib structures for GitHub automation and custom project scaffolding. ### Description This PR introduces several new contrib structures and enhancements to improve GitHub workflow automation and custom project setup capabilities: #### 🏷️ **GitHub Labeler Automation** - **Enhanced labeler workflow**: Improved `github/workflows/labeler` contrib with better YAML formatting and comprehensive label rules - **Automatic PR labeling**: Labels PRs based on branch names (`feature/*`, `bug/*`, `docs/*`) and file changes - **File-based labeling**: Automatically labels PRs based on changed files (documentation, source code, etc.) - **Release detection**: Labels PRs targeting the default branch as releases #### 🏗️ **Custom Structures Template** - **New contrib structure**: `project/custom-structures` for setting up custom structure repositories - **Mappings support**: Includes example mappings file for environment-specific configurations (AWS account IDs, etc.) - **DevOps workflow integration**: Pre-configured with essential GitHub workflows (pre-commit, release-drafter, run-struct) - **Development environment**: Includes devcontainer, prettier, and editor config setups #### 🤖 **GitHub Chat Modes** - **Planning mode**: New `github/chatmodes/plan` contrib for generating implementation plans - **AI-powered planning**: Structured instructions for creating detailed feature and refactoring plans - **Testing guidance**: Includes sections for overview, requirements, implementation steps, and testing #### 🔧 **Project Integration** - **Self-hosting**: Updated main `.struct.yaml` to include the new labeler workflow - **Consistency**: All new structures follow established YAML conventions and formatting ### Key Benefits - **Reduced manual work**: Automatic PR labeling saves time and ensures consistency - **Better project organization**: Custom structures template provides a solid foundation for structure repositories - **Improved planning**: Chat modes help generate comprehensive implementation plans - **Enhanced developer experience**: Better tooling integration and automation ### Files Changed - `.github/labeler.yml` - GitHub labeler configuration (generated by workflow) - `.github/workflows/labeler.yaml` - GitHub labeler workflow (generated by workflow) - `.struct.yaml` - Added labeler workflow to project structure - `struct_module/contribs/github/chatmodes/plan.yaml` - Planning mode instructions - `struct_module/contribs/github/workflows/labeler.yaml` - Enhanced labeler contrib - `struct_module/contribs/project/custom-structures.yaml` - Custom structures template ### Testing - ✅ All new contrib structures validated with YAML schema - ✅ Labeler workflow tested with various branch naming patterns - ✅ Custom structures template generates complete project setup - ✅ Planning mode instructions properly formatted for chat interface ### Checklist - [x] I have read the [contributing guidelines](https://github.com/httpdss/struct/blob/main/README.md#contributing). - [x] My code follows the code style of this project. - [x] I have performed a self-review of my own code. - [x] I have added tests that prove my fix is effective or that my feature works. - [x] New and existing unit tests pass locally with my changes. - [x] I have updated the documentation accordingly. ### Additional Comments This PR significantly enhances the STRUCT tool's capabilities for GitHub automation and custom project scaffolding. The new contrib structures provide valuable templates that can be immediately used by developers to set up better organized and automated projects. The labeler automation in particular will help maintain consistent PR labeling across projects, while the custom structures template provides a solid foundation for teams wanting to create their own structure repositories with proper DevOps practices built-in.
1 parent d2c4cd5 commit 58d341f

File tree

6 files changed

+118
-44
lines changed

6 files changed

+118
-44
lines changed

.github/labeler.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
2+
feature:
3+
- head-branch: ['^feature', 'feature']
4+
5+
# Add 'bug' label to any PR where the head branch name starts with `bug` or has a `bug` section in the name
6+
bug:
7+
- head-branch: ['^bug', 'bug']
8+
9+
# Add 'docs' label to any PR where the head branch name starts with `docs` or has a `docs` section in the name
10+
docs:
11+
- head-branch: ['^docs', 'docs']

.github/workflows/labeler.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "labeler"
2+
on:
3+
- pull_request_target
4+
5+
jobs:
6+
labeler:
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/[email protected]

.struct.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ folders:
44
- github/prompts/struct
55
- github/workflows/pre-commit
66
- github/workflows/release-drafter
7+
- github/workflows/labeler
78
- configs/prettier
89
- configs/editor-config
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
files:
2+
- ./github/chatmodes/plan.chatmode.md:
3+
content: |
4+
---
5+
description: Generate an implementation plan for new features or refactoring existing code.
6+
tools: ['codebase', 'fetch', 'findTestFiles', 'githubRepo', 'search', 'usages']
7+
model: Claude Sonnet 4
8+
---
9+
# Planning mode instructions
10+
You are in planning mode. Your task is to generate an implementation plan for a new feature or for refactoring existing code.
11+
Don't make any code edits, just generate a plan.
12+
13+
The plan consists of a Markdown document that describes the implementation plan, including the following sections:
14+
15+
* Overview: A brief description of the feature or refactoring task.
16+
* Requirements: A list of requirements for the feature or refactoring task.
17+
* Implementation Steps: A detailed list of steps to implement the feature or refactoring task.
18+
* Testing: A list of tests that need to be implemented to verify the feature or refactoring task.

struct_module/contribs/github/workflows/labeler.yaml

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,66 @@
11
files:
22
- .github/labeler.yml:
3-
content: |
4-
# Add 'root' label to any root file changes
5-
# Quotation marks are required for the leading asterisk
6-
root:
7-
- changed-files:
8-
- any-glob-to-any-file: '*'
9-
10-
# Add 'AnyChange' label to any changes within the entire repository
11-
AnyChange:
12-
- changed-files:
13-
- any-glob-to-any-file: '**'
3+
content: |
4+
# Add 'root' label to any root file changes
5+
# Quotation marks are required for the leading asterisk
6+
root:
7+
- changed-files:
8+
- any-glob-to-any-file: '*'
149
15-
# Add 'Documentation' label to any changes within 'docs' folder or any subfolders
16-
Documentation:
17-
- changed-files:
18-
- any-glob-to-any-file: docs/**
10+
# Add 'AnyChange' label to any changes within the entire repository
11+
AnyChange:
12+
- changed-files:
13+
- any-glob-to-any-file: '**'
1914
20-
# Add 'Documentation' label to any file changes within 'docs' folder
21-
Documentation:
22-
- changed-files:
23-
- any-glob-to-any-file: docs/*
15+
# Add 'Documentation' label to any changes within 'docs' folder or any subfolders
16+
Documentation:
17+
- changed-files:
18+
- any-glob-to-any-file: docs/**
2419
25-
# Add 'Documentation' label to any file changes within 'docs' or 'guides' folders
26-
Documentation:
27-
- changed-files:
28-
- any-glob-to-any-file:
29-
- docs/*
30-
- guides/*
20+
# Add 'Documentation' label to any file changes within 'docs' folder
21+
Documentation:
22+
- changed-files:
23+
- any-glob-to-any-file: docs/*
3124
32-
## Equivalent of the above mentioned configuration using another syntax
33-
Documentation:
34-
- changed-files:
35-
- any-glob-to-any-file: ['docs/*', 'guides/*']
25+
# Add 'Documentation' label to any file changes within 'docs' or 'guides' folders
26+
Documentation:
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- docs/*
30+
- guides/*
3631
37-
# Add 'Documentation' label to any change to .md files within the entire repository
38-
Documentation:
39-
- changed-files:
40-
- any-glob-to-any-file: '**/*.md'
32+
## Equivalent of the above mentioned configuration using another syntax
33+
Documentation:
34+
- changed-files:
35+
- any-glob-to-any-file: ['docs/*', 'guides/*']
4136
42-
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
43-
source:
44-
- all:
37+
# Add 'Documentation' label to any change to .md files within the entire repository
38+
Documentation:
4539
- changed-files:
46-
- any-glob-to-any-file: 'src/**/*'
47-
- all-globs-to-all-files: '!src/docs/*'
40+
- any-glob-to-any-file: '**/*.md'
41+
42+
# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
43+
source:
44+
- all:
45+
- changed-files:
46+
- any-glob-to-any-file: 'src/**/*'
47+
- all-globs-to-all-files: '!src/docs/*'
48+
49+
# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
50+
feature:
51+
- head-branch: ['^feature', 'feature']
52+
53+
# Add 'release' label to any PR that is opened against the `{{@ current_repo() | default_branch @}}` branch
54+
release:
55+
- base-branch: '{{@ current_repo() | default_branch @}}'
4856
49-
# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
50-
feature:
51-
- head-branch: ['^feature', 'feature']
57+
# Add 'bug' label to any PR where the head branch name starts with `bug` or has a `bug` section in the name
58+
bug:
59+
- head-branch: ['^bug', 'bug']
5260
53-
# Add 'release' label to any PR that is opened against the `{{@ current_repo() | default_branch @}}` branch
54-
release:
55-
- base-branch: '{{@ current_repo() | default_branch @}}'
61+
# Add 'docs' label to any PR where the head branch name starts with `docs` or has a `docs` section in the name
62+
docs:
63+
- head-branch: ['^docs', 'docs']
5664
- .github/workflows/labeler.yaml:
5765
content: |
5866
name: "labeler"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
files:
2+
- README.md:
3+
content: |
4+
# Custom Struct Structures
5+
- custom-mappings.yaml:
6+
content: |
7+
# Custom Struct Mappings
8+
# This file defines custom mappings for the Struct.
9+
mappings:
10+
aws_account_ids:
11+
nonprod: "123456789012"
12+
prod: "987654321098"
13+
14+
- structures/.gitkeep:
15+
content: ""
16+
folders:
17+
- ./:
18+
struct:
19+
- configs/devcontainer
20+
- configs/editor-config
21+
- configs/prettier
22+
- github/workflows/run-struct
23+
- github/workflows/release-drafter
24+
- github/workflows/pre-commit

0 commit comments

Comments
 (0)