chore: 初始化仓库

This commit is contained in:
Lydanne
2026-02-15 22:02:21 +08:00
commit 08d011d63f
381 changed files with 87202 additions and 0 deletions

49
.github/workflows/pr-review-command.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
name: PR Review Command
on:
issue_comment:
types: [created]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
review:
# 仅在 PR 评论中触发,且评论以 /review 或 /ai-review 开头
if: |
github.event.issue.pull_request &&
(startsWith(github.event.comment.body, '/review') || startsWith(github.event.comment.body, '/ai-review'))
runs-on: ubuntu-node-24
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Set pnpm registry to npmmirror
run: |
pnpm config set registry https://registry.npmmirror.com
pnpm install -g @anthropic-ai/claude-code
pnpm install -g opencode-ai
- name: Run Review
uses: ./actions
env:
GIT_PROVIDER_TYPE: gitea
CLAUDE_CODE_BASE_URL: https://ark.cn-beijing.volces.com/api/coding
CLAUDE_CODE_AUTH_TOKEN: ${{ secrets.CLAUDE_CODE_AUTH_TOKEN }}
OPENAI_BASE_URL: https://ark.cn-beijing.volces.com/api/v3
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: deepseek-v3-2-251201
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
from-comment: ${{ github.event.comment.body }}
dev-mode: "true"

51
.github/workflows/pr-review.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: PR Review
on:
pull_request:
types: [opened, synchronize, reopened, closed]
permissions:
contents: read # 仓库内容:只读
pull-requests: write # PR可写比如评论PR
issues: write # Issues可写
deployments: read # 部署:只读
id-token: write # ID Token可写
pages: write # Pages可写
packages: write # Packages可写
repository-projects: write # Repository Projects可写
security-events: write # Security Events可写
workflows: write # Workflows可写
jobs:
pr-review:
runs-on: ubuntu-node-24
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Set pnpm registry to npmmirror
run: |
pnpm config set registry https://registry.npmmirror.com
pnpm install -g @anthropic-ai/claude-code
pnpm install -g opencode-ai
- name: Run Review
uses: ./actions
env:
GIT_PROVIDER_TYPE: gitea
CLAUDE_CODE_BASE_URL: https://ark.cn-beijing.volces.com/api/coding
CLAUDE_CODE_AUTH_TOKEN: ${{ secrets.CLAUDE_CODE_AUTH_TOKEN }}
OPENAI_BASE_URL: https://ark.cn-beijing.volces.com/api/v3
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: deepseek-v3-2-251201
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: review
args: -vv -l openai
event-action: ${{ github.event.action }}
dev-mode: "true"

66
.github/workflows/publish.yml vendored Normal file
View File

@@ -0,0 +1,66 @@
name: Publish
on:
push:
branches:
- main
workflow_dispatch:
inputs:
dry_run:
description: "Dry run mode (不实际执行)"
required: false
default: false
type: boolean
rehearsal:
description: "Rehearsal mode (执行 hooks 但不修改文件/git)"
required: false
default: false
type: boolean
env:
GIT_PROVIDER_TYPE: gitea
GITHUB_TOKEN: ${{ secrets.CI_GITEA_TOKEN }}
jobs:
publish:
runs-on: ubuntu-node-24
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.CI_GITEA_TOKEN }}
fetch-depth: 0
fetch-tags: true
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Git and NPM
run: |
git config user.name "GiteaActions"
git config user.email "GiteaActions@users.noreply.gitea.com"
echo "@spaceflow:registry=https://git.bjxgj.com/api/packages/xgj/npm/" >> .npmrc
echo "//git.bjxgj.com/api/packages/xgj/npm/:_authToken=${{ secrets.CI_GITEA_TOKEN }}" >> .npmrc
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run setup
- name: Install Extensions
run: pnpm spaceflow install
- name: Publish (Dry Run)
if: ${{ github.event.inputs.dry_run == 'true' }}
run: pnpm spaceflow publish --dry-run --ci
- name: Publish (Rehearsal)
if: ${{ github.event.inputs.rehearsal == 'true' && github.event.inputs.dry_run != 'true' }}
run: pnpm spaceflow publish --rehearsal --ci
- name: Publish
if: ${{ github.event.inputs.dry_run != 'true' && github.event.inputs.rehearsal != 'true' }}
run: pnpm spaceflow publish --ci

59
.github/workflows/test-actions.yml vendored Normal file
View File

@@ -0,0 +1,59 @@
name: Test Actions
on:
workflow_dispatch:
inputs:
command:
description: "Command to test"
required: true
type: choice
options:
- publish
- review
- ci-scripts
- ci-shell
args:
description: "Additional arguments for the command"
required: false
type: string
default: "--dry-run"
dev-mode:
description: "Enable development mode"
required: false
type: boolean
default: true
jobs:
test-action:
runs-on: ubuntu-node-20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Set pnpm registry to npmmirror
run: |
pnpm config set registry https://registry.npmmirror.com
pnpm install -g @anthropic-ai/claude-code
pnpm install -g opencode-ai
- name: Test spaceflow action
uses: ./actions
env:
GIT_PROVIDER_TYPE: gitea
CLAUDE_CODE_BASE_URL: https://ark.cn-beijing.volces.com/api/coding
CLAUDE_CODE_AUTH_TOKEN: ${{ secrets.CLAUDE_CODE_AUTH_TOKEN }}
OPENAI_BASE_URL: https://ark.cn-beijing.volces.com/api/v3
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: deepseek-v3-2-251201
# OPENAI_MODEL: doubao-seed-code-preview-251028
# OPENAI_MODEL: glm-4-7-251222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: ${{ inputs.command }}
args: ${{ inputs.args }}
dev-mode: ${{ inputs.dev-mode }}

View File

@@ -0,0 +1,51 @@
name: Test Branch Protection
on:
workflow_dispatch:
jobs:
test-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Debug Tokens and Permissions
run: |
echo "=== Token Info ==="
echo "GITHUB_TOKEN length: ${#GITHUB_TOKEN}"
echo "GITHUB_TOKEN prefix: ${GITHUB_TOKEN:0:10}..."
echo ""
echo "=== Git Remote URL ==="
git remote -v
echo ""
echo "=== GitHub API User Info ==="
curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/user"
echo ""
echo ""
echo "=== Check Token Repo Permissions ==="
curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${{ github.repository }}" | grep -E '"permissions"|"admin"|"push"|"pull"'
echo ""
echo "=== Full Repo Info (permissions section) ==="
curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${{ github.repository }}" | jq '.permissions' 2>/dev/null || \
curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${{ github.repository }}" | grep -o '"permissions":{[^}]*}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Write ci.md and commit
run: |
echo "Test commit at $(date)" >> ci.md
git add ci.md
git commit -m "test: branch protection test [no ci]"
git push

76
.github/workflows/test-command.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
name: Run Spaceflow Command
on:
workflow_dispatch:
inputs:
command:
description: "Command to run (publish, review, ci-scripts, ci-shell, claude-config)"
required: true
type: choice
options:
- publish
- review
- ci-scripts
- ci-shell
- claude-config
args:
description: "Additional arguments for the command"
required: false
type: string
default: ""
dry-run:
description: "Run in dry-run mode"
required: false
type: boolean
default: true
jobs:
run-command:
runs-on: ubuntu-node-20
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Init submodules
# run: |
# git submodule sync --recursive
# git submodule update --init --recursive
- name: Print environment variables
run: |
echo "=== Environment Variables ==="
env | sort
echo "============================="
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
run: |
pnpm config set registry https://registry.npmmirror.com
pnpm install -g @anthropic-ai/claude-code
pnpm install -g opencode-ai
pnpm install --frozen-lockfile
- name: Build all packages
run: pnpm run setup
- name: Install spaceflow plugins
run: pnpm spaceflow install --ignore-errors
- name: Run spaceflow command
env:
GIT_PROVIDER_TYPE: gitea
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLAUDE_CODE_BASE_URL: https://ark.cn-beijing.volces.com/api/coding
CLAUDE_CODE_AUTH_TOKEN: ${{ secrets.CLAUDE_CODE_AUTH_TOKEN }}
OPENAI_BASE_URL: https://ark.cn-beijing.volces.com/api/v3
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: deepseek-v3-2-251201
run: |
ARGS="${{ inputs.args }}"
if [ "${{ inputs.dry-run }}" = "true" ]; then
ARGS="$ARGS --dry-run"
fi
pnpm spaceflow ${{ inputs.command }} $ARGS