diff --git a/.github/workflows/auto-fix.yml b/.github/workflows/auto-fix.yml new file mode 100644 index 00000000..97e34bab --- /dev/null +++ b/.github/workflows/auto-fix.yml @@ -0,0 +1,93 @@ +name: Auto-fix V3 Validation Errors + +on: + pull_request_target: + branches: + - main + paths: + - '**.md' + - '**.yaml' + - 'ci/**' + +jobs: + auto-fix: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout PR branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r ci/requirements.txt + + - name: Generate code blocks + run: python ci/copy_code_blocks.py + continue-on-error: true + + - name: Run auto-fix validation + run: python -m ci.auto_fix_validation --apply + continue-on-error: true + + - name: Check for changes + id: check_changes + run: | + if [[ -n $(git status --porcelain) ]]; then + echo "has_changes=true" >> $GITHUB_OUTPUT + echo "Changes detected:" + git status --short + else + echo "has_changes=false" >> $GITHUB_OUTPUT + echo "No changes detected" + fi + + - name: Commit and push changes + if: steps.check_changes.outputs.has_changes == 'true' + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Auto-fix V3 validation errors [bot]" + git push + + - name: Comment on PR + if: steps.check_changes.outputs.has_changes == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue_number = context.issue.number; + const comment_body = `🤖 **Auto-fix Applied** + + I've automatically fixed common V3 validation errors in this PR: + - Generated code blocks from markdown files + - Fixed purple_chat_link URLs + - Fixed slug format issues + - Updated agent_capabilities + - Added missing solution_tags + - Removed invalid fields + + The changes have been committed and pushed. Please review the auto-fixes and ensure they're correct. + + The validation workflow will run separately to verify all fixes.`; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: comment_body + });