diff --git a/.github/workflows/ai-maintenance-manual.yml b/.github/workflows/ai-maintenance-manual.yml index 00f4d9b..775bbf4 100644 --- a/.github/workflows/ai-maintenance-manual.yml +++ b/.github/workflows/ai-maintenance-manual.yml @@ -2,104 +2,8 @@ on: workflow_dispatch: -permissions: - contents: write - pull-requests: write - jobs: - audit_and_fix: + ping: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: "20" - - - name: Install audit tools - run: | - npm i -g linkinator@6 htmlhint@1 markdownlint-cli@0.41 lighthouse@12 - - - name: Link check (live site) - run: | - linkinator --recurse --timeout 10000 https://www.oradigit.com \ - --format JSON > link-report.json || true - - - name: HTML lint - run: | - htmlhint "**/*.html" --format json > htmlhint-report.json || true - - - name: Markdown lint - run: | - markdownlint "**/*.md" -j > md-report.json || true - - - name: Lighthouse (homepage) - run: | - npx lighthouse https://www.oradigit.com --quiet \ - --output=json --output-path=./lighthouse-home.json \ - --only-categories=performance,accessibility,seo || true - - - name: Summarize audit - run: | - node - <<'NODE' - const fs = require('fs'); - function load(p){ try { return JSON.parse(fs.readFileSync(p,'utf8')) } catch { return null } } - const summary = { - when: new Date().toISOString(), - linkReport: load('link-report.json'), - htmlhint: load('htmlhint-report.json'), - mdlint: load('md-report.json'), - lighthouse: load('lighthouse-home.json') - }; - fs.writeFileSync('audit-summary.json', JSON.stringify(summary, null, 2)); - console.log('Wrote audit-summary.json'); - NODE - - - name: Ask Firebase Function for patch - env: - FB_FUNCTION_URL: ${{ vars.FB_FUNCTION_URL }} - FB_AUTHTOKEN: ${{ secrets.FIREBASE_AUTOMATION_TOKEN }} - run: | - node - <<'NODE' - const fs = require('fs'); - const url = process.env.FB_FUNCTION_URL; - const token = process.env.FB_AUTHTOKEN; - const audit = JSON.parse(fs.readFileSync('audit-summary.json','utf8')); - (async () => { - const r = await fetch(url, { - method: 'POST', - headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' }, - body: JSON.stringify({ audit }) - }); - const data = await r.json().catch(() => ({})); - fs.writeFileSync('fb-response.json', JSON.stringify(data, null, 2)); - if (data.ok && data.patch && data.patch.includes('--- ') && data.patch.includes('+++ ')) { - fs.writeFileSync('ai.patch', data.patch); - console.log('Got patch from Firebase function.'); - } else { - console.log('No valid diff from Firebase function; exiting gracefully.'); - process.exit(0); - } - })(); - NODE - - - name: Apply patch and commit - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - BR=ai/maint-${GITHUB_RUN_ID} - git checkout -b "$BR" - git apply --whitespace=fix ai.patch || { echo "Patch failed"; exit 0; } - git add -A - git commit -m "AI maintenance: automated fixes" || { echo "Nothing to commit"; exit 0; } - echo "PR_BRANCH=$BR" >> $GITHUB_ENV - - - name: Create Pull Request - if: env.PR_BRANCH != '' - uses: peter-evans/create-pull-request@v6 - with: - branch: ${{ env.PR_BRANCH }} - title: AI maintenance: automated fixes - body: Automated PR with small, safe improvements based on audits. - commit-message: AI maintenance: automated fixes - base: main + - run: echo "Manual workflow is wired correctly."