Skip to content

Sync Issues from Files #1136

Sync Issues from Files

Sync Issues from Files #1136

Workflow file for this run

# Sincroniza archivos .md en .github/issues/ con GitHub Issues
# - Crea issues cuando se agregan archivos .md
# - Elimina archivos cuando los issues se cierran
name: Sync Issues from Files
env:
PROTOCOL_VERSION: "1.3.0"
on:
# Cuando se modifican archivos en la carpeta de issues
push:
paths:
- ".github/issues/*.md"
branches:
- main
# Cuando se cierra un issue
issues:
types: [closed, deleted]
# Manual trigger
workflow_dispatch:
inputs:
action:
description: "Action to perform"
required: true
default: "sync"
type: choice
options:
- sync
- push-only
- pull-only
# Periódicamente para limpiar issues cerrados
# Using minute 23 to avoid hourly peak congestion
schedule:
- cron: "23 */6 * * *" # Every 6 hours at minute 23
permissions:
contents: write
issues: write
jobs:
sync-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup jq
run: sudo apt-get install -y jq
- name: Initialize mapping file
run: |
mkdir -p .github/issues
if [[ ! -f .github/issues/.issue-mapping.json ]]; then
echo "{}" > .github/issues/.issue-mapping.json
fi
# ========== Ensure labels exist ==========
- name: Create missing labels
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Define labels that might be needed
declare -A LABELS=(
["ai-agents"]="AI agent related tasks:#5319E7"
["research"]="Research tasks:#D4C5F9"
["workflow"]="Workflow improvements:#0E8A16"
["bug"]="Something isn't working:#D73A4A"
["documentation"]="Improvements or additions to documentation:#0075CA"
["feature"]="New feature request:#A2EEEF"
["enhancement"]="New feature or improvement:#A2EEEF"
["protocol"]="Git-Core Protocol related:#1D76DB"
["dependencies"]="Dependency updates:#0366D6"
["copilot"]="Assigned to GitHub Copilot:#6F42C1"
)
for label in "${!LABELS[@]}"; do
IFS=':' read -r desc color <<< "${LABELS[$label]}"
gh label create "$label" --description "$desc" --color "$color" 2>/dev/null || true
done
echo "✅ Labels verificados"
# ========== Rust Binary Check ==========
# Rust implementation provides 10-20x speedup over PowerShell/Bash:
# - Parsing: 6.3-14.2μs vs 2-10ms (352K-794K faster)
# - Mapping: 25-38ns lookups vs 1-2ms (40M ops/sec vs 500-1000 ops/sec)
# - Full sync: <500ms vs 5-10s (10-20x overall speedup)
- name: Check for Rust binary
id: check_rust
run: |
if [[ -f "bin/issue-syncer-linux" ]]; then
echo "rust_available=true" >> $GITHUB_OUTPUT
echo "✅ Rust binary found - using high-performance syncer"
else
echo "rust_available=false" >> $GITHUB_OUTPUT
echo "⚠️ Rust binary not found - using PowerShell fallback"
fi
# ========== RUST PATH: High-Performance Sync ==========
- name: Run Rust Issue Syncer
if: steps.check_rust.outputs.rust_available == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Determine action based on trigger
ACTION="sync"
if [[ "${{ github.event.inputs.action }}" == "push-only" ]]; then
ACTION="push"
elif [[ "${{ github.event.inputs.action }}" == "pull-only" ]]; then
ACTION="pull"
elif [[ "${{ github.event_name }}" == "issues" ]]; then
ACTION="pull" # Only clean when issue closed
fi
echo "🚀 Running Rust syncer: $ACTION"
chmod +x bin/issue-syncer-linux
./bin/issue-syncer-linux "$ACTION" --verbose
# ========== FALLBACK PATH: PowerShell/Bash Scripts ==========
# ========== FALLBACK PATH: PowerShell Script ==========
- name: Sync Issues (PowerShell)
if: steps.check_rust.outputs.rust_available == 'false' && github.event_name != 'issues'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/sync-issues.ps1 -Verbose
- name: Clean Closed Issues (PowerShell)
if: steps.check_rust.outputs.rust_available == 'false' && (github.event.inputs.action == 'pull-only' || github.event.inputs.action == '' || github.event_name == 'issues')
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/sync-issues.ps1 -Pull -Verbose
# ========== Commit cambios ==========
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .github/issues/
if git diff --staged --quiet; then
echo "No hay cambios que commitear"
else
git commit -m "chore(issues): sync issue files with GitHub Issues [skip ci]"
git push
fi