assembly-automation-hub/repo-governance

GitHub: assembly-automation-hub/repo-governance

一个以 YAML 为中心的 GitHub 仓库治理套件,将 CI/CD、依赖更新、安全扫描与问题模板统一编排,解决维护流程分散与策略不可审计的问题。

Stars: 2 | Forks: 1


                                                                                           

                               ,,        ,,                 ,,                             

                             `7MM      `7MM               `7MM                             

                               MM        MM                 MM                             

`7M'   `MF'`7MMpMMMb.pMMMb.    MM        MMpMMMb.  .gP"Ya   MM `7MMpdMAo.  .gP"Ya `7Mb,od8 

  VA   ,V    MM    MM    MM    MM        MM    MM ,M'   Yb  MM   MM   `Wb ,M'   Yb  MM' "' 

   VA ,V     MM    MM    MM    MM        MM    MM 8M""""""  MM   MM    M8 8M""""""  MM     

    VVV      MM    MM    MM    MM        MM    MM YM.    ,  MM   MM   ,AP YM.    ,  MM     

    ,V     .JMML  JMML  JMML..JMML.    .JMML  JMML.`Mbmmd'.JMML. MMbmmd'   `Mbmmd'.JMML.   

   ,V                                                            MM                        

OOb"                                                           .JMML.                      

A repository-automation and delivery blueprint for a logging library, consolidating GitHub Actions, dependency governance, security scanning, issue intake, and maintainer funding metadata in one place.

[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue?style=for-the-badge)](LICENSE)

[![CI: Lint](https://img.shields.io/badge/CI-Lint%20and%20Static%20Checks-181717?style=for-the-badge&logo=githubactions)](#testing)

[![Security: CodeQL](https://img.shields.io/badge/Security-CodeQL-2ea44f?style=for-the-badge&logo=github)](#deployment)

[![Dependabot](https://img.shields.io/badge/Dependencies-Dependabot-025e8c?style=for-the-badge&logo=dependabot)](#configuration)

[![YAML First](https://img.shields.io/badge/Config-YAML-informational?style=for-the-badge)](#tech-stack--architecture)

## 目录 - [Title and Description](#yml_helper) - [Features](#features) - [Tech Stack & Architecture](#tech-stack--architecture) - [Core Stack](#core-stack) - [Project Structure](#project-structure) - [What Each YAML File Does](#what-each-yaml-file-does) - [Key Design Decisions](#key-design-decisions) - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Testing](#testing) - [Deployment](#deployment) - [Usage](#usage) - [Configuration](#configuration) - [GitHub Actions Secrets](#github-actions-secrets) - [Workflow Triggers and Inputs](#workflow-triggers-and-inputs) - [Funding Metadata](#funding-metadata) - [Issue Template Configuration](#issue-template-configuration) - [License](#license) - [Contacts & Community Support](#contacts--community-support) ## 特性 - Centralizes GitHub repository automation for a logging-library project in auditable YAML manifests. - Enforces dependency hygiene with scheduled `Dependabot` updates for both Python and GitHub Actions ecosystems. - Auto-approves and auto-merges safe `Dependabot` patch and minor upgrades to reduce maintenance overhead. - Runs lint-oriented pull request checks, including Node.js bootstrap, optional package-lock generation, and JavaScript syntax validation. - Executes scheduled and on-demand `CodeQL` SAST scanning for JavaScript and TypeScript attack-surface analysis. - Provides an AI-assisted issue generation workflow that can inspect pushes and pull requests and execute a Python analysis entrypoint. - Standardizes issue intake through structured bug-report and feature-request forms. - Ships a reusable pull-request template that captures change type, validation steps, and review hygiene. - Publishes maintainer funding channels through GitHub Sponsors-compatible metadata. - Keeps repository operations declarative, reviewable, and easy to fork or transplant into another logging-related project. ## 技术栈与架构 ### 核心栈 - `YAML`: Primary configuration language for GitHub Actions workflows, issue forms, funding configuration, and dependency automation. - `Markdown`: Human-facing project documentation and pull-request template content. - `GitHub Actions`: CI/CD orchestration and policy execution engine. - `Node.js 20`: Used by the lint workflow to install dependencies and run optional linting or syntax checks. - `Python 3.11`: Used by the AI-analysis workflow to execute `trigger action/trigger_action.py` with GitHub event context. - `CodeQL`: Static Application Security Testing engine for JavaScript/TypeScript analysis. - `Dependabot`: Automated update management for package and GitHub Action dependency drift. ### 项目结构 ``` . ├── .github/ │ ├── FUNDING.yml │ ├── dependabot.yml │ ├── pull_request_template.md │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.yml │ │ └── feature_request.yml │ └── workflows/ │ ├── ai-issue.yml │ ├── dependabot-auto-merge.yml │ ├── lint.yml │ └── sast.yml ├── LICENSE ├── README.md └── trigger action/ └── trigger_action.py ``` ### 每个 YAML 文件的作用 The repository is intentionally small, so every YAML file has a specific operational role: | File | Purpose | Operational Impact | | --- | --- | --- | | `.github/FUNDING.yml` | Declares GitHub-recognized funding platforms and custom donation links. | Exposes support links in the repository UI and centralizes maintainer sponsorship metadata. | | `.github/dependabot.yml` | Configures weekly update scans for `pip` and `github-actions`. | Keeps Python dependencies and workflow action versions from drifting or missing security patches. | | `.github/workflows/ai-issue.yml` | Runs an AI-assisted analysis pipeline on `push` to `main` and selected pull-request events. | Installs Python dependencies, injects GitHub event metadata, and executes `trigger action/trigger_action.py` to create or enrich issues. | | `.github/workflows/dependabot-auto-merge.yml` | Reviews pull requests opened by `dependabot[bot]`. | Automatically approves and enables merge automation for safe patch/minor dependency updates. | | `.github/workflows/lint.yml` | Performs pull-request lint and static validation. | Bootstraps Node.js, creates `package-lock.json` when absent, optionally runs the repo lint script, and validates JavaScript syntax under `api/`. | | `.github/workflows/sast.yml` | Executes `CodeQL` static analysis. | Scans JavaScript/TypeScript code on PRs, manual dispatches, and a weekly schedule to surface security findings. | | `.github/ISSUE_TEMPLATE/bug_report.yml` | Structured bug report form. | Forces reproducibility details, expected behavior, actual traces, and environment context. | | `.github/ISSUE_TEMPLATE/feature_request.yml` | Structured feature proposal form. | Captures problem context, proposed solution, and alternatives for roadmap triage. | ### 关键设计决策 1. `GitHub-native automation over custom infrastructure` - The project leans on built-in GitHub primitives such as Actions, issue forms, scheduled workflows, repository funding, and PR templates. - This keeps the operational surface area small and avoids maintaining a separate CI orchestrator. 2. `Policy as code` - Maintenance behavior is encoded in version-controlled YAML rather than implicit repository settings. - Every workflow change can be reviewed, diffed, and audited like application code. 3. `Separation of concerns` - Dependency updates, security scanning, linting, and AI-assisted triage each live in distinct workflow files. - This improves debuggability and reduces accidental coupling between maintenance tasks. 4. `Safe-by-default automation` - Auto-merge is restricted to non-breaking `Dependabot` patch/minor updates. - Higher-risk changes still require human review. 5. `Mixed runtime support` - The repository anticipates both Python-centric automation (`trigger action/trigger_action.py`) and JavaScript/TypeScript code scanning/linting. - This is a pragmatic design for logging projects that may expose SDKs, CLIs, dashboards, or integrations across multiple runtimes. #### 工作流拓扑 ``` flowchart TD A[Developer Push / Pull Request] --> B[GitHub Actions Triggers] B --> C[Lint Workflow] B --> D[CodeQL SAST Workflow] B --> E[AI Issue Workflow] F[Dependabot Update] --> G[Dependabot Metadata] G --> H[Auto-Approve Safe Updates] H --> I[Enable Auto-Merge] C --> J[Node.js Setup and Validation] D --> K[Security Findings] E --> L[Python Analysis Entry Point] L --> M[Generated or Enriched Issues] ``` #### 日志库交付上下文 ``` sequenceDiagram participant Dev as Maintainer participant GH as GitHub participant CI as Actions Runner participant Sec as CodeQL participant Bot as Dependabot Dev->>GH: Open pull request GH->>CI: Trigger lint.yml GH->>Sec: Trigger sast.yml Sec-->>GH: Upload security results CI-->>GH: Publish validation status Bot->>GH: Open dependency PR GH->>CI: Trigger dependabot-auto-merge.yml CI-->>GH: Approve and enable auto-merge when safe ``` ## 快速开始 ### 先决条件 To work with this repository locally, you should have: - `git` for cloning and version-control operations. - `Node.js 20` and `npm` to emulate the lint workflow locally. - `Python 3.11` and `pip` to emulate the AI workflow dependency installation. - A GitHub repository with Actions enabled if you the workflows to execute end to end. - Optional: `gh` CLI for testing PR-review or merge commands used by the Dependabot automation. ### 安装 1. Clone the repository. 2. Enter the project directory. 3. Install the runtime dependencies you need for local workflow emulation. ``` git clone cd yml_helper npm install --no-audit --no-fund pip install PyGithub requests ``` If your logging library lives in a separate repository, copy or vendor the `.github/` directory into that project and then tailor the workflow assumptions to the actual code layout. ## 测试 This repository does not currently ship an application test suite. Validation is primarily configuration- and workflow-oriented. ### 推荐的本地检查 ``` # Markdown 和仓库卫生 cat README.md # 在 yq 可用时验证 YAML 语法 yq '.' .github/dependabot.yml > /dev/null yq '.' .github/FUNDING.yml > /dev/null yq '.' .github/workflows/ai-issue.yml > /dev/null yq '.' .github/workflows/dependabot-auto-merge.yml > /dev/null yq '.' .github/workflows/lint.yml > /dev/null yq '.' .github/workflows/sast.yml > /dev/null yq '.' .github/ISSUE_TEMPLATE/bug_report.yml > /dev/null yq '.' .github/ISSUE_TEMPLATE/feature_request.yml > /dev/null # 重现基于节点的 lint 工作流行为 npm install --no-audit --no-fund npm run lint --if-present # 如果存在 api/ 目录则验证 JavaScript 语法 find api -type f -name '*.js' -print0 | xargs -0 -I{} node --check "{}" ``` ### GitHub 端检查 - Open a pull request to trigger `lint.yml` and `sast.yml`. - Use `workflow_dispatch` for manual execution of `lint.yml` or `sast.yml`. - Open a test `Dependabot` PR or modify `dependabot.yml` schedules to validate update automation. - Push to `main` or open a pull request to validate `ai-issue.yml` using `trigger action/trigger_action.py`. ## 部署 For this repository, “deployment” means rolling workflow and governance changes into a GitHub repository used by the logging library. ### 生产发布模型 1. Merge workflow changes into the default branch. 2. Ensure repository secrets are populated before enabling workflows that depend on them. 3. Confirm GitHub Actions permissions align with the workflow declarations. 4. Observe the first scheduled or manually dispatched runs for permissions and path mismatches. ### CI/CD 集成指导 - Treat `.github/workflows/*.yml` as production infrastructure code. - Require pull-request review for workflow changes. - Use protected branches so auto-merge only operates after required checks succeed. - Keep the CodeQL schedule enabled for baseline security drift detection. - Version workflow logic alongside the logging library code so release branches inherit the correct automation posture. ### 容器化 There is no Dockerfile or Compose stack in the current repository snapshot. If your logging library is containerized elsewhere, mount or copy this `.github/` configuration into that source repository rather than trying to “deploy” this repository as a standalone service. ## 用法 Because this project is automation-first, usage is mostly operational rather than API-driven. ### 示例:在日志库仓库中采用该工作流集 ``` # 克隆你的日志库仓库 cd /path/to/logging-library # 将自动化资产复制到目标仓库 cp -R /path/to/yml_helper/.github . cp /path/to/yml_helper/README.md ./docs/repo-automation.md ``` ### 示例:自定义 Dependabot 计划 ``` version: 2 updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" # Increase scan frequency for security-sensitive projects labels: - "dependencies" - "python" ``` ### 示例:调用 AI 工作流先决条件 ``` # 安装 ai-issue.yml 所需的 Python 依赖项 pip install PyGithub requests # 提供与 GitHub Actions 中相同的环境变量 export GITHUB_TOKEN="" export REPOSITORY="owner/repo" export EVENT_NAME="pull_request" export COMMIT_SHA="" export PR_NUMBER="123" export GH_MODELS_TOKEN="" export ALLOWED_USER="" # 运行分析入口点 python "trigger action/trigger_action.py" ``` ### 示例:lint 工作流行为 ``` # 在本地镜像 GitHub Actions lint 作业 npm install --no-audit --no-fund npm run lint --if-present # 当仓库包含 api/ 目录时验证 JavaScript 文件 if [ -d api ]; then find api -type f -name '*.js' -print0 | xargs -0 -I{} node --check "{}" fi ``` ## 配置 ### GitHub Actions 密钥 The repository references the following secrets and environment variables: | Name | Required By | Purpose | | --- | --- | --- | | `GITHUB_TOKEN` | Multiple workflows | Authenticates GitHub API and CLI actions using the repository-scoped token. | | `GH_MODELS_TOKEN` | `ai-issue.yml` | Supplies credentials for the AI model provider consumed by `trigger action/trigger_action.py`. | | `ALLOWED_USER` | `ai-issue.yml` | Constrains or validates which actor may use the AI-assisted workflow behavior. | | `REPOSITORY` | `ai-issue.yml` | Passes the current `owner/name` repository identifier into the Python entrypoint. | | `EVENT_NAME` | `ai-issue.yml` | Provides the GitHub event type being processed. | | `COMMIT_SHA` | `ai-issue.yml` | Provides the commit under analysis. | | `PR_NUMBER` | `ai-issue.yml` | Provides the pull request number when available. | | `GH_TOKEN` | `dependabot-auto-merge.yml` | Authenticates `gh pr review` and `gh pr merge` operations. | ### 工作流触发器和输入 | Workflow | Trigger | Key Runtime Assumptions | | --- | --- | --- | | `ai-issue.yml` | `push` to `main`; PR events `opened`, `synchronize`, `labeled` | Requires `trigger action/trigger_action.py`, Python 3.11, GitHub and model tokens. | | `dependabot-auto-merge.yml` | Dependabot PR `opened`, `reopened`, `synchronize`, `ready_for_review` | Requires `gh` CLI on runner and permissions to write PR metadata. | | `lint.yml` | Any pull request; manual dispatch | Assumes a Node-capable repository and optionally an `api/` directory. | | `sast.yml` | Any pull request; manual dispatch; weekly Monday cron | Assumes JavaScript/TypeScript code is present for CodeQL to analyze. | ### 资助元数据 `.github/FUNDING.yml` currently advertises the following support channels: - `GitHub Sponsors`: `OstinUA` - `Patreon`: `OstinFCT` - `Ko-fi`: `fctostin` - `Boosty`: custom URL - `Telegram`: custom URL - `YouTube`: custom URL ### 问题模板配置 The issue forms are opinionated and useful for operational maturity: - `bug_report.yml` emphasizes duplicate checks, exact environment details, reproducible steps, expected behavior, and traceback capture. - `feature_request.yml` emphasizes problem framing, proposed solution narratives, and alternative approaches. ## 许可证 This repository is licensed under the Apache License 2.0. See [`LICENSE`](LICENSE) for the full text. ## 联系与社区支持 ## 支持该项目 [![Patreon](https://img.shields.io/badge/Patreon-OstinFCT-f96854?style=flat-square&logo=patreon)](https://www.patreon.com/OstinFCT) [![Ko-fi](https://img.shields.io/badge/Ko--fi-fctostin-29abe0?style=flat-square&logo=ko-fi)](https://ko-fi.com/fctostin) [![Boosty](https://img.shields.io/badge/Boosty-Support-f15f2c?style=flat-square)](https://boosty.to/ostinfct) [![YouTube](https://img.shields.io/badge/YouTube-FCT--Ostin-red?style=flat-square&logo=youtube)](https://www.youtube.com/@FCT-Ostin) [![Telegram](https://img.shields.io/badge/Telegram-FCTostin-2ca5e0?style=flat-square&logo=telegram)](https://t.me/FCTostin) If you find this tool useful, consider leaving a star on GitHub or supporting the author directly.
标签:AI辅助, Apache-2.0, CI/CD安全, CodeQL, Dependabot, GitHub Actions, Llama, MITM代理, PR上传, SAST, XML注入, YAML配置, 交付蓝图, 仓库治理, 仓库自动化, 依赖治理, 安全扫描, 安全评估工具, 开源治理, 日志库, 时序注入, 浏览器插件, 特权提升, 盲注攻击, 结构化模板, 维护者资金元数据, 自动化部署, 自动合并, 自动笔记, 许可证徽章, 逆向工具, 问题生成, 问题采集, 静态检查