Skip to content
This repository was archived by the owner on Oct 25, 2025. It is now read-only.

πŸ€– Auto-Fix Common Issues #2

πŸ€– Auto-Fix Common Issues

πŸ€– Auto-Fix Common Issues #2

Workflow file for this run

name: πŸ€– Auto-Fix Common Issues
on:
workflow_dispatch:
inputs:
fix_type:
description: 'Type of fix to apply'
required: true
default: 'all'
type: choice
options:
- all
- linting
- dependencies
- formatting
- security
schedule:
# Run weekly maintenance on Sundays at 2 AM
- cron: '0 2 * * 0'
permissions:
contents: write
pull-requests: write
jobs:
auto-fix:
name: πŸ”§ Automated Maintenance
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: πŸ“₯ Checkout code
uses: actions/checkout@v5.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: βš™οΈ Set up Node.js 22.x
uses: actions/setup-node@v4.4.0
with:
node-version: 22.x
- name: πŸš€ Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: πŸ“¦ Install dependencies
run: bun install --frozen-lockfile
- name: 🧹 Auto-fix linting and formatting
if: github.event.inputs.fix_type == 'all' || github.event.inputs.fix_type == 'linting' || github.event.inputs.fix_type == 'formatting'
run: |
echo "🧹 Running auto-fix for linting and formatting..."
# Save current state
git stash push -m "Pre-autofix state" || true
# Apply fixes
bun run lint:fix || true
bun run format || true
# Check for changes
if ! git diff --quiet; then
echo "βœ… Applied auto-fixes"
echo "LINTING_FIXED=true" >> $GITHUB_ENV
else
echo "ℹ️ No linting issues to fix"
echo "LINTING_FIXED=false" >> $GITHUB_ENV
fi
- name: πŸ”’ Security updates
if: github.event.inputs.fix_type == 'all' || github.event.inputs.fix_type == 'security'
run: |
echo "πŸ”’ Checking for security updates..."
# Check for vulnerabilities
if npm audit --audit-level=moderate; then
echo "βœ… No security vulnerabilities found"
echo "SECURITY_FIXED=false" >> $GITHUB_ENV
else
echo "πŸ”§ Applying security fixes..."
npm audit fix --force || true
if ! git diff --quiet package*.json; then
echo "βœ… Applied security fixes"
echo "SECURITY_FIXED=true" >> $GITHUB_ENV
else
echo "ℹ️ No security fixes applied"
echo "SECURITY_FIXED=false" >> $GITHUB_ENV
fi
fi
- name: πŸ“¦ Update dependencies
if: github.event.inputs.fix_type == 'all' || github.event.inputs.fix_type == 'dependencies'
run: |
echo "πŸ“¦ Checking for dependency updates..."
# Check for outdated packages (excluding major versions)
npm outdated --json > outdated.json || true
if [ -s outdated.json ]; then
echo "πŸ“¦ Found outdated dependencies"
# Update patch and minor versions only
npx npm-check-updates -u --target minor || true
npm install || true
if ! git diff --quiet package*.json; then
echo "βœ… Updated dependencies"
echo "DEPS_UPDATED=true" >> $GITHUB_ENV
else
echo "ℹ️ No dependency updates available"
echo "DEPS_UPDATED=false" >> $GITHUB_ENV
fi
else
echo "βœ… All dependencies are up to date"
echo "DEPS_UPDATED=false" >> $GITHUB_ENV
fi
rm -f outdated.json
- name: πŸ§ͺ Validate changes
if: contains(github.env, 'LINTING_FIXED=true') || contains(github.env, 'SECURITY_FIXED=true') || contains(github.env, 'DEPS_UPDATED=true')
run: |
echo "πŸ§ͺ Validating all changes..."
# Run validation pipeline
npm run validate
if [ $? -eq 0 ]; then
echo "βœ… All validations passed"
echo "VALIDATION_PASSED=true" >> $GITHUB_ENV
else
echo "❌ Validation failed, reverting changes"
git reset --hard HEAD
git clean -fd
echo "VALIDATION_PASSED=false" >> $GITHUB_ENV
exit 1
fi
- name: πŸ“ Generate change summary
if: contains(github.env, 'VALIDATION_PASSED=true')
id: changes
run: |
echo "πŸ“ Generating change summary..."
SUMMARY=""
if [ "$LINTING_FIXED" = "true" ]; then
SUMMARY="$SUMMARY\n- 🧹 Applied Biome linting and formatting fixes"
fi
if [ "$SECURITY_FIXED" = "true" ]; then
SUMMARY="$SUMMARY\n- πŸ”’ Applied security updates"
fi
if [ "$DEPS_UPDATED" = "true" ]; then
SUMMARY="$SUMMARY\n- πŸ“¦ Updated dependencies"
fi
if [ -n "$SUMMARY" ]; then
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
echo "SUMMARY<<EOF" >> $GITHUB_OUTPUT
echo -e "$SUMMARY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
fi
- name: πŸš€ Commit and push changes
if: steps.changes.outputs.HAS_CHANGES == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "πŸ€– Auto-maintenance: Weekly fixes and updates
${{ steps.changes.outputs.SUMMARY }}
- πŸ”„ Automated by GitHub Actions (scheduled)
- βœ… All validations passed
- πŸ“… Run on: $(date +'%Y-%m-%d %H:%M:%S UTC')
[skip ci]"
git push
- name: πŸ“Š Report results
if: always()
run: |
echo "πŸ“Š Auto-fix Results Summary:"
echo "🧹 Linting fixes applied: ${LINTING_FIXED:-false}"
echo "πŸ”’ Security fixes applied: ${SECURITY_FIXED:-false}"
echo "πŸ“¦ Dependencies updated: ${DEPS_UPDATED:-false}"
echo "βœ… Validation passed: ${VALIDATION_PASSED:-false}"
if [ "${{ steps.changes.outputs.HAS_CHANGES }}" = "true" ]; then
echo "πŸŽ‰ Auto-maintenance completed successfully!"
else
echo "ℹ️ No changes were needed"
fi