feat: add GitHub issue templates and CI workflows for automatic releases and PR size limits

This commit is contained in:
MengMengCode
2026-09-18 18:58:07 +08:00
parent ad9e646607
commit 18a548f1fd
6 changed files with 516 additions and 1 deletions
+107
View File
@@ -0,0 +1,107 @@
name: Bug Report / 问题反馈
description: 报告 CLICD 运行或功能中的异常与错误 / Report a bug or problem with CLICD
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
感谢提交反馈!请尽可能完整填写以下信息,协助我们快速定位和排查问题。
Thanks for taking the time to report this issue! Please provide the details below so we can diagnose and resolve it quickly.
- type: checkboxes
id: existing-issues
attributes:
label: 历史 Issue 查重 / Check Existing Issues
description: 请确认是否已检索过类似问题 / Please confirm you checked past issues
options:
- label: 我已检索过历史 Issue(含已关闭条目),确认暂无相同或高度相似的问题报告 / I searched existing issues and found no duplicate
required: true
- type: textarea
id: description
attributes:
label: 现象描述 / What Happened
description: 清晰描述遇到的问题以及你期望的表现 / Describe what went wrong and what you expected to happen
placeholder: 请简要描述问题现象与预期表现...
validations:
required: true
- type: dropdown
id: virtualization-type
attributes:
label: 虚拟化类型 / Virtualization Type
description: 问题涉及的虚拟化后端 / Affected virtualization backend
options:
- LXC
- KVM
- Both (LXC & KVM)
- WebUI / Panel / Other
validations:
required: true
- type: input
id: clicd-version
attributes:
label: CLICD 版本 / CLICD Version
description: 运行的 CLICD 版本号 / CLICD version (e.g. v1.1.29)
placeholder: "v1.1.29"
validations:
required: true
- type: input
id: host-os
attributes:
label: 宿主机系统与内核 / Host OS & Kernel
description: 运行节点的 Linux 发行版与内核版本 / Linux distribution and kernel version
placeholder: "Debian 12 / Ubuntu 22.04 / Proxmox VE 8.2 (Linux 6.8.x)"
validations:
required: true
- type: dropdown
id: architecture
attributes:
label: 架构 / Architecture
description: 宿主机 CPU 架构 / Host CPU architecture
options:
- x86_64 / amd64
- aarch64 / arm64
- Other
validations:
required: true
- type: dropdown
id: deployment-method
attributes:
label: 部署方式 / Deployment Method
description: 你是通过何种方式部署 CLICD 的? / How did you deploy CLICD?
options:
- 一键脚本 (install.sh / systemd)
- 预编译二进制 (Prebuilt Binary)
- 源码编译 (Built from Source)
- 智简魔方模块 (Mofang Module)
- 其他 (Other)
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: 复现步骤 / Steps to Reproduce
description: 导致该问题出现的具体操作步骤 / Steps to reproduce the behavior
placeholder: |
1. 进入...
2. 点击...
3. 出现错误...
validations:
required: false
- type: textarea
id: error-logs
attributes:
label: 错误日志与终端输出 / Error Logs
description: 请粘贴相关日志(例如 `journalctl -u clicd`、`/var/log/clicd.log` 或浏览器控制台信息)/ Paste relevant logs or console output
placeholder: 粘贴错误日志或命令输出...
render: shell
validations:
required: false
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: "CLICD 文档与使用指南 / Documentation"
url: "https://mengmengcode.github.io/CLICD/"
about: "查阅 CLICD 部署安装、网络配置与 API 接口指南 / View setup, networking, and API guides"
@@ -0,0 +1,46 @@
name: Feature Request / 功能建议
description: 为 CLICD 提出新功能、改进建议或优化设想 / Suggest an idea or enhancement for CLICD
title: "[Feature]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
感谢为 CLICD 提出建设性意见!请尽可能详细阐述你的需求背景与设想。
Thank you for suggesting an idea! Please explain the problem you're trying to solve and how CLICD can help.
- type: textarea
id: problem-statement
attributes:
label: 需求背景与痛点 / Problem or Motivation
description: 这个功能解决了什么问题?是否对应现有的操作阻碍? / Is your feature request related to a problem?
placeholder: 当我尝试做某项操作时,目前无法...
validations:
required: true
- type: textarea
id: proposed-solution
attributes:
label: 期望的解决方案 / Proposed Solution
description: 清晰描述你希望新增或改善的交互与逻辑 / Clear description of what you want to happen
placeholder: 希望增加支持...,面板上增加...
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: 替代方案或临时方案 / Alternatives Considered
description: 你目前是如何绕过或处理这个问题的? / Any alternative solutions or features you've considered
placeholder: 目前通过手动命令行执行...
validations:
required: false
- type: textarea
id: additional-context
attributes:
label: 补充说明 / Additional Context
description: 任何其他相关的设计草图、截图或参考资料 / Add any other context or screenshots
placeholder: 补充信息...
validations:
required: false
+163
View File
@@ -0,0 +1,163 @@
name: Automatic release threshold
on:
push:
branches:
- main
- master
# Recheck once a day in case a branch-push run was skipped or interrupted.
schedule:
- cron: "17 3 * * *"
workflow_dispatch:
permissions:
actions: write
contents: write
concurrency:
group: automatic-release-main
cancel-in-progress: false
jobs:
check-and-release:
name: Release after 500 changed code lines
runs-on: ubuntu-latest
timeout-minutes: 10
env:
RELEASE_THRESHOLD: "500"
steps:
- name: Checkout complete history
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate changes since the latest stable version
id: plan
shell: bash
env:
HEAD_SHA: ${{ github.sha }}
run: |
set -euo pipefail
# Tags are the release counter: every manual or automatic stable
# release resets the accumulated source-code difference.
git fetch --force --tags origin
BASE_TAG=""
while IFS= read -r candidate; do
if [[ "${candidate}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
BASE_TAG="${candidate}"
break
fi
done < <(git tag --merged "${HEAD_SHA}" --sort=-version:refname)
if [[ -z "${BASE_TAG}" ]]; then
echo "::error::No stable vMAJOR.MINOR.PATCH tag is reachable from ${HEAD_SHA}."
exit 1
fi
NUMSTAT_FILE="$(mktemp)"
trap 'rm -f "${NUMSTAT_FILE}"' EXIT
# Count real source changes, but ignore documentation,
# artwork, dependency lock files, build artifacts, and repo metadata.
git diff --numstat "${BASE_TAG}" "${HEAD_SHA}" -- . \
':(exclude)README.md' \
':(exclude)api.md' \
':(exclude)docs/**' \
':(exclude)img/**' \
':(exclude)LICENSE' \
':(exclude)linux.txt' \
':(exclude)backend/go.sum' \
':(exclude)frontend/package-lock.json' \
':(exclude)docs/package-lock.json' \
':(exclude)frontend/dist/**' \
':(exclude)dist/**' \
':(exclude)build/**' \
':(exclude).github/**' \
':(exclude).vscode/**' \
':(exclude).claude/**' \
> "${NUMSTAT_FILE}"
read -r ADDITIONS DELETIONS < <(
awk '
$1 ~ /^[0-9]+$/ && $2 ~ /^[0-9]+$/ {
additions += $1
deletions += $2
}
END { printf "%d %d\n", additions, deletions }
' "${NUMSTAT_FILE}"
)
CHANGED_LINES=$((ADDITIONS + DELETIONS))
VERSION="${BASE_TAG#v}"
IFS=. read -r MAJOR MINOR PATCH <<< "${VERSION}"
NEXT_TAG="v${MAJOR}.${MINOR}.$((PATCH + 1))"
SHOULD_RELEASE=false
if (( CHANGED_LINES >= RELEASE_THRESHOLD )); then
SHOULD_RELEASE=true
fi
{
echo "base_tag=${BASE_TAG}"
echo "next_tag=${NEXT_TAG}"
echo "additions=${ADDITIONS}"
echo "deletions=${DELETIONS}"
echo "changed_lines=${CHANGED_LINES}"
echo "should_release=${SHOULD_RELEASE}"
} >> "${GITHUB_OUTPUT}"
{
echo "### Automatic release threshold"
echo
echo "- Base version: \`${BASE_TAG}\`"
echo "- Target commit: \`${HEAD_SHA}\`"
echo "- Additions: ${ADDITIONS}"
echo "- Deletions: ${DELETIONS}"
echo "- Total changed code lines: ${CHANGED_LINES}/${RELEASE_THRESHOLD}"
echo "- Release required: ${SHOULD_RELEASE}"
if [[ "${SHOULD_RELEASE}" == "true" ]]; then
echo "- Next version: \`${NEXT_TAG}\`"
fi
} >> "${GITHUB_STEP_SUMMARY}"
- name: Create the next patch-version tag
if: steps.plan.outputs.should_release == 'true'
shell: bash
env:
HEAD_SHA: ${{ github.sha }}
NEXT_TAG: ${{ steps.plan.outputs.next_tag }}
run: |
set -euo pipefail
# A remote existence check makes a manual release racing this job
# fail safely instead of overwriting an existing version tag.
if git ls-remote --exit-code --tags origin "refs/tags/${NEXT_TAG}" >/dev/null 2>&1; then
echo "::error::Tag ${NEXT_TAG} already exists; rerun to recalculate from the new baseline."
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${NEXT_TAG}" "${HEAD_SHA}" -m "CLICD ${NEXT_TAG#v}"
git push origin "refs/tags/${NEXT_TAG}"
- name: Start build and release workflow
if: steps.plan.outputs.should_release == 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
NEXT_TAG: ${{ steps.plan.outputs.next_tag }}
run: |
set -euo pipefail
# Tag pushes made with GITHUB_TOKEN do not trigger other workflows,
# so dispatch build.yml explicitly at the tag.
gh workflow run build.yml --repo "${GITHUB_REPOSITORY}" --ref "${NEXT_TAG}"
{
echo
echo "Dispatched build and release workflow for \`${NEXT_TAG}\`."
} >> "${GITHUB_STEP_SUMMARY}"
+3 -1
View File
@@ -56,6 +56,8 @@ jobs:
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "CLICD_VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_ENV"
elif [[ "$GITHUB_REF_NAME" == v* ]]; then
echo "CLICD_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
else
echo "CLICD_VERSION=dev" >> "$GITHUB_ENV"
fi
@@ -105,7 +107,7 @@ jobs:
name: Publish GitHub Release
needs: linux
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref_name, 'v')
steps:
- name: Checkout
+192
View File
@@ -0,0 +1,192 @@
name: Pull request size limit
on:
pull_request_target:
branches:
- main
- master
types:
- opened
- synchronize
- reopened
- ready_for_review
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: pr-size-limit-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
enforce-size-limit:
name: Enforce 3,000-line limit
runs-on: ubuntu-latest
timeout-minutes: 5
env:
MAX_CHANGED_LINES: "3000"
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ github.token }}
steps:
- name: Check conflicts and pull request size via GitHub API
shell: bash
run: |
set -euo pipefail
echo "Checking PR #${PR_NUMBER}"
############################################################
# Helper: comment on and close rejected PR
############################################################
reject_pr() {
local message="$1"
echo "::error::${message}"
COMMENT_PAYLOAD="$(
jq -nc \
--arg body "${message}" \
'{body: $body}'
)"
echo "Posting rejection comment..."
curl \
--fail-with-body \
--silent \
--show-error \
--request POST \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${GH_TOKEN}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
--data "${COMMENT_PAYLOAD}" \
>/dev/null
echo "Closing PR #${PR_NUMBER}..."
curl \
--fail-with-body \
--silent \
--show-error \
--request PATCH \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${GH_TOKEN}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" \
--data '{"state":"closed"}' \
>/dev/null
exit 1
}
############################################################
# Fetch PR metadata from GitHub REST API
############################################################
echo "Fetching pull request metadata from GitHub API..."
PR_JSON=""
for attempt in {1..10}; do
PR_JSON="$(
curl \
--fail-with-body \
--silent \
--show-error \
--request GET \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${GH_TOKEN}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}"
)"
MERGEABLE="$(echo "${PR_JSON}" | jq -r '.mergeable')"
if [[ "${MERGEABLE}" != "null" ]]; then
break
fi
echo "Mergeable state is calculating, waiting 2s (attempt ${attempt}/10)..."
sleep 2
done
MERGEABLE="$(echo "${PR_JSON}" | jq -r '.mergeable')"
ADDITIONS="$(echo "${PR_JSON}" | jq -r '.additions // 0')"
DELETIONS="$(echo "${PR_JSON}" | jq -r '.deletions // 0')"
CHANGED_FILES="$(echo "${PR_JSON}" | jq -r '.changed_files // 0')"
CHANGED_LINES=$((ADDITIONS + DELETIONS))
############################################################
# STEP 1: Reject PRs with merge conflicts
############################################################
echo
echo "Checking for merge conflicts..."
if [[ "${MERGEABLE}" == "false" ]]; then
{
echo "### Pull request policy"
echo
echo "- Merge conflicts: ❌ Detected"
echo "- Result: Rejected"
} >> "${GITHUB_STEP_SUMMARY}"
reject_pr "This pull request has merge conflicts with the target branch and cannot be accepted. Please update your branch with the latest changes, resolve all merge conflicts locally, and submit a conflict-free pull request."
fi
echo "No merge conflicts detected (mergeable: ${MERGEABLE})."
############################################################
# Action summary
############################################################
{
echo "### Pull request policy"
echo
echo "- Merge conflicts: ✅ None"
echo "- Changed files: ${CHANGED_FILES}"
echo "- Additions: ${ADDITIONS}"
echo "- Deletions: ${DELETIONS}"
echo "- Total changed lines: ${CHANGED_LINES}"
echo "- Maximum allowed: ${MAX_CHANGED_LINES}"
} >> "${GITHUB_STEP_SUMMARY}"
echo
echo "Changed files: ${CHANGED_FILES}"
echo "Additions: ${ADDITIONS}"
echo "Deletions: ${DELETIONS}"
echo "Total changed lines: ${CHANGED_LINES}"
echo "Limit: ${MAX_CHANGED_LINES}"
############################################################
# STEP 2: Reject oversized PRs
############################################################
if (( CHANGED_LINES > MAX_CHANGED_LINES )); then
reject_pr "This pull request changes ${CHANGED_LINES} lines (${ADDITIONS} additions + ${DELETIONS} deletions) across ${CHANGED_FILES} files, exceeding the repository limit of ${MAX_CHANGED_LINES} changed lines. It has been closed automatically. Please split the changes into smaller pull requests."
fi
############################################################
# PASS
############################################################
echo
echo "Pull request passed all policy checks."
echo "No merge conflicts."
echo "Changed lines: ${CHANGED_LINES}/${MAX_CHANGED_LINES}."
{
echo
echo "### Result"
echo
echo "✅ Pull request passed."
} >> "${GITHUB_STEP_SUMMARY}"