|
| 1 | +name: "GEO Audit — AI-Readiness Score" |
| 2 | +description: "Audit any website's AI-readiness. Scores 20 rules across discoverability, structured data, content quality, and technical readiness. Returns 0-100 score with A-F grade." |
| 3 | +author: "GLINCKER" |
| 4 | + |
| 5 | +branding: |
| 6 | + icon: search |
| 7 | + color: green |
| 8 | + |
| 9 | +inputs: |
| 10 | + url: |
| 11 | + description: "URL to audit (e.g. https://example.com)" |
| 12 | + required: true |
| 13 | + fail-under: |
| 14 | + description: "Minimum score threshold — fail the step if score is below this value (0 = never fail)" |
| 15 | + required: false |
| 16 | + default: "0" |
| 17 | + comment: |
| 18 | + description: "Post score as a PR comment (requires pull_request trigger and write permissions)" |
| 19 | + required: false |
| 20 | + default: "false" |
| 21 | + badge: |
| 22 | + description: "Include badge markdown snippet in the output" |
| 23 | + required: false |
| 24 | + default: "false" |
| 25 | + timeout: |
| 26 | + description: "Fetch timeout in milliseconds" |
| 27 | + required: false |
| 28 | + default: "15000" |
| 29 | + version: |
| 30 | + description: "Specific @glincker/geo-audit version to use (default: latest)" |
| 31 | + required: false |
| 32 | + default: "latest" |
| 33 | + |
| 34 | +outputs: |
| 35 | + score: |
| 36 | + description: "Numeric score (0-100)" |
| 37 | + value: ${{ steps.audit.outputs.score }} |
| 38 | + grade: |
| 39 | + description: "Letter grade (A, B, C, D, or F)" |
| 40 | + value: ${{ steps.audit.outputs.grade }} |
| 41 | + badge: |
| 42 | + description: "Static shields.io badge URL for this score" |
| 43 | + value: ${{ steps.audit.outputs.badge }} |
| 44 | + result: |
| 45 | + description: "Full JSON audit result" |
| 46 | + value: ${{ steps.audit.outputs.result }} |
| 47 | + |
| 48 | +runs: |
| 49 | + using: composite |
| 50 | + steps: |
| 51 | + - name: Setup Node.js |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: "20" |
| 55 | + |
| 56 | + - name: Run GEO Audit |
| 57 | + id: audit |
| 58 | + shell: bash |
| 59 | + env: |
| 60 | + INPUT_URL: ${{ inputs.url }} |
| 61 | + INPUT_TIMEOUT: ${{ inputs.timeout }} |
| 62 | + INPUT_VERSION: ${{ inputs.version }} |
| 63 | + INPUT_FAIL_UNDER: ${{ inputs.fail-under }} |
| 64 | + INPUT_BADGE: ${{ inputs.badge }} |
| 65 | + run: | |
| 66 | + set -euo pipefail |
| 67 | +
|
| 68 | + # Install and run audit |
| 69 | + RESULT=$(npx --yes "@glincker/geo-audit@${INPUT_VERSION}" "${INPUT_URL}" --json --timeout "${INPUT_TIMEOUT}" 2>/dev/null) || { |
| 70 | + echo "::error::Failed to audit ${INPUT_URL}. Check the URL is accessible." |
| 71 | + exit 1 |
| 72 | + } |
| 73 | +
|
| 74 | + # Parse score and grade safely |
| 75 | + SCORE=$(echo "$RESULT" | node -e " |
| 76 | + const d = require('fs').readFileSync('/dev/stdin','utf8'); |
| 77 | + try { console.log(JSON.parse(d).score); } |
| 78 | + catch { console.log('-1'); } |
| 79 | + ") |
| 80 | + GRADE=$(echo "$RESULT" | node -e " |
| 81 | + const d = require('fs').readFileSync('/dev/stdin','utf8'); |
| 82 | + try { console.log(JSON.parse(d).grade); } |
| 83 | + catch { console.log('?'); } |
| 84 | + ") |
| 85 | +
|
| 86 | + if [ "$SCORE" = "-1" ] || [ "$GRADE" = "?" ]; then |
| 87 | + echo "::error::Failed to parse audit result for ${INPUT_URL}" |
| 88 | + exit 1 |
| 89 | + fi |
| 90 | +
|
| 91 | + # Grade → color mapping |
| 92 | + case "$GRADE" in |
| 93 | + A) COLOR="brightgreen"; EMOJI="🟢" ;; |
| 94 | + B) COLOR="green"; EMOJI="🟢" ;; |
| 95 | + C) COLOR="yellow"; EMOJI="🟡" ;; |
| 96 | + D) COLOR="orange"; EMOJI="🟠" ;; |
| 97 | + *) COLOR="red"; EMOJI="🔴" ;; |
| 98 | + esac |
| 99 | +
|
| 100 | + # Build static badge URL |
| 101 | + BADGE_URL="https://img.shields.io/badge/AI--Ready-${SCORE}%20(${GRADE})-${COLOR}" |
| 102 | +
|
| 103 | + # Set outputs |
| 104 | + echo "score=${SCORE}" >> "$GITHUB_OUTPUT" |
| 105 | + echo "grade=${GRADE}" >> "$GITHUB_OUTPUT" |
| 106 | + echo "badge=${BADGE_URL}" >> "$GITHUB_OUTPUT" |
| 107 | +
|
| 108 | + # Multiline JSON output |
| 109 | + EOF_MARKER="EOF_$(head -c 15 /dev/urandom | base64 | tr -d '/+=')" |
| 110 | + { |
| 111 | + echo "result<<${EOF_MARKER}" |
| 112 | + echo "$RESULT" |
| 113 | + echo "${EOF_MARKER}" |
| 114 | + } >> "$GITHUB_OUTPUT" |
| 115 | +
|
| 116 | + # Job Summary (always written — shows in Actions tab) |
| 117 | + { |
| 118 | + echo "## ${EMOJI} AI-Readiness Report" |
| 119 | + echo "" |
| 120 | + echo "| Metric | Value |" |
| 121 | + echo "|--------|-------|" |
| 122 | + echo "| **URL** | \`${INPUT_URL}\` |" |
| 123 | + echo "| **Score** | **${SCORE}/100** |" |
| 124 | + echo "| **Grade** | **${GRADE}** |" |
| 125 | + echo "" |
| 126 | + echo "" |
| 127 | + echo "" |
| 128 | +
|
| 129 | + # Top recommendations from JSON |
| 130 | + echo "$RESULT" | node -e " |
| 131 | + const d = require('fs').readFileSync('/dev/stdin','utf8'); |
| 132 | + const j = JSON.parse(d); |
| 133 | + const recs = j.recommendations || []; |
| 134 | + if (recs.length > 0) { |
| 135 | + console.log('### Top Recommendations'); |
| 136 | + console.log(''); |
| 137 | + recs.slice(0, 5).forEach((r, i) => { |
| 138 | + console.log(\`\${i+1}. \${r.message} *(+\${r.impact} pts)*\`); |
| 139 | + }); |
| 140 | + console.log(''); |
| 141 | + } |
| 142 | + " |
| 143 | +
|
| 144 | + if [ "${INPUT_BADGE}" = "true" ]; then |
| 145 | + echo "### Badge Snippet" |
| 146 | + echo "" |
| 147 | + echo "\`\`\`markdown" |
| 148 | + echo "[](https://geo.glincker.com)" |
| 149 | + echo "\`\`\`" |
| 150 | + echo "" |
| 151 | + fi |
| 152 | +
|
| 153 | + echo "---" |
| 154 | + echo "*Powered by [GEO Audit](https://geo.glincker.com) — AI-Readiness scoring for the modern web*" |
| 155 | + } >> "$GITHUB_STEP_SUMMARY" |
| 156 | +
|
| 157 | + # Console output |
| 158 | + echo "${EMOJI} GEO Audit: ${INPUT_URL}" |
| 159 | + echo " Score: ${SCORE}/100 (${GRADE})" |
| 160 | +
|
| 161 | + # Threshold check |
| 162 | + if [ "${INPUT_FAIL_UNDER}" -gt 0 ] 2>/dev/null && [ "${SCORE}" -lt "${INPUT_FAIL_UNDER}" ]; then |
| 163 | + echo "::error::Score ${SCORE} is below threshold ${INPUT_FAIL_UNDER}" |
| 164 | + exit 1 |
| 165 | + fi |
| 166 | +
|
| 167 | + - name: Comment on PR |
| 168 | + if: inputs.comment == 'true' && github.event_name == 'pull_request' |
| 169 | + uses: actions/github-script@v7 |
| 170 | + with: |
| 171 | + script: | |
| 172 | + const score = '${{ steps.audit.outputs.score }}'; |
| 173 | + const grade = '${{ steps.audit.outputs.grade }}'; |
| 174 | + const badge = '${{ steps.audit.outputs.badge }}'; |
| 175 | + const emoji = { A: '🟢', B: '🟢', C: '🟡', D: '🟠', F: '🔴' }; |
| 176 | + const e = emoji[grade] || '⚪'; |
| 177 | +
|
| 178 | + // Find and update existing comment (avoid spam) |
| 179 | + const { data: comments } = await github.rest.issues.listComments({ |
| 180 | + owner: context.repo.owner, |
| 181 | + repo: context.repo.repo, |
| 182 | + issue_number: context.issue.number, |
| 183 | + }); |
| 184 | + const existing = comments.find(c => |
| 185 | + c.user.type === 'Bot' && c.body.includes('AI-Readiness Report') |
| 186 | + ); |
| 187 | +
|
| 188 | + const body = [ |
| 189 | + `## ${e} AI-Readiness Report`, |
| 190 | + '', |
| 191 | + `| Metric | Value |`, |
| 192 | + `|--------|-------|`, |
| 193 | + `| **URL** | \`${{ inputs.url }}\` |`, |
| 194 | + `| **Score** | **${score}/100** |`, |
| 195 | + `| **Grade** | **${grade}** |`, |
| 196 | + '', |
| 197 | + ``, |
| 198 | + '', |
| 199 | + `---`, |
| 200 | + `*Powered by [GEO Audit](https://geo.glincker.com)*`, |
| 201 | + ].join('\n'); |
| 202 | +
|
| 203 | + if (existing) { |
| 204 | + await github.rest.issues.updateComment({ |
| 205 | + owner: context.repo.owner, |
| 206 | + repo: context.repo.repo, |
| 207 | + comment_id: existing.id, |
| 208 | + body, |
| 209 | + }); |
| 210 | + } else { |
| 211 | + await github.rest.issues.createComment({ |
| 212 | + owner: context.repo.owner, |
| 213 | + repo: context.repo.repo, |
| 214 | + issue_number: context.issue.number, |
| 215 | + body, |
| 216 | + }); |
| 217 | + } |
0 commit comments