Skip to content

Add alt text check workflow#11268

Open
Arshvinth wants to merge 4 commits intowso2:masterfrom
Arshvinth:add-alt-text-check-workflow
Open

Add alt text check workflow#11268
Arshvinth wants to merge 4 commits intowso2:masterfrom
Arshvinth:add-alt-text-check-workflow

Conversation

@Arshvinth
Copy link
Copy Markdown

Purpose

Problem: PRs sometimes add images without alt text, harming accessibility and SEO.
Files: .github/workflows/alt-text-check.yml
Resolves: N/A

Goals

Primary: Automatically detect images in Markdown that lack alt text and fail the PR check so authors fix them before merge.
Secondary: Raise awareness of accessibility best practices among contributors.

Approach

Implementation: Add a GitHub Actions workflow that runs on pull requests and performs two checks:
Greps Markdown for empty Markdown image alt text patterns ( /  ).
Greps for HTML tags inside Markdown that are missing an alt attribute.
File changed: .github/workflows/alt-text-check.yml
Behavior: If any matches are found the job prints the locations and exits non‑zero, causing the PR check to fail. No edits to content are made automatically — authors must fix the files.

User stories

Doc writer: As a doc author, I want an automated check so I don't forget to add alt text.
Reviewer: As a reviewer, I want CI to surface missing alt text so reviews focus on substance.
Accessibility owner: As an accessibility reviewer, I want a lightweight enforcement point in CI to improve site accessibility.

Release note

Docs: Add automated PR check to flag images missing alt text in Markdown.

Documentation

Updated config: See .github/workflows/alt-text-check.yml.

Training

N/A

Certification

N/A

Marketing

N/A

Automation tests

Type: CI workflow (GitHub Actions) — runs on pull_request.
Unit tests: N/A
Integration tests: N/A

Security checks

Secure coding guidelines followed: N/A (workflow is configuration-only)
FindSecurityBugs run: N/A
Secrets check: yes — this change commits no keys, passwords, tokens, or credentials.

Samples

N/A

Related PRs

None (this is an independent CI addition)

Migrations (if applicable)

None

Test environment

Runner: GitHub Actions ubuntu-latest (workflow runs on pull requests).

Learning

Notes: Simple grep-based checks are effective for catching common omissions (empty Markdown alt text or missing alt attributes in HTML). This approach is intentionally conservative (reports potential misses rather than attempting automatic fixes). Recommended follow-ups: add a broken-link check and a markdown-lint job to further improve doc quality.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Changes

Workflow Addition: Introduces a new GitHub Actions workflow that automatically checks pull requests for images in Markdown files lacking alt text. The workflow runs git grep to detect:

  • Markdown image syntax with empty alt text (![](...) and ![ ](...))
  • HTML <img> tags missing an alt attribute

If matches are found, the workflow outputs offending line locations and fails the PR check. The check applies to Markdown files under en/**/*.md and runs on ubuntu-latest.

Documentation Updates: Minor corrections to two documentation files:

  • Fixed grammar by adding missing article in one sentence
  • Re-applied an identical line in a role-based access control guide

Impact

Adds automated accessibility and SEO validation to the PR review process by flagging images without alt text, helping raise contributor awareness of accessibility best practices.

Walkthrough

This pull request introduces a new GitHub Actions workflow to validate image alt text in Markdown documentation files. The workflow detects empty alt text in Markdown image syntax (![](...) format) and missing alt attributes in HTML <img> tags, failing the check if any are found. Additionally, two documentation files receive minor corrections: a single-line replacement in the role-based access control documentation and a grammar correction in the distributed deployment guide that adds the missing article "the" in a sentence.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: adding a GitHub Actions workflow for alt text validation in Markdown files.
Description check ✅ Passed The description covers all required template sections with substantial detail: purpose, goals, approach, user stories, release note, documentation, and testing/security information are all addressed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/alt-text-check.yml:
- Line 18: The regex used to populate html_missing_alt (the git grep pattern
"<img\b(?![^>]*\balt=)[^>]*>") is too permissive and case-sensitive; update the
pattern used in html_missing_alt to use case-insensitive matching and require a
whitespace boundary around alt (e.g., prefix with (?i) and replace \balt= with
\salt\s*=) so it catches <IMG> and avoids matching attributes like data-alt=
while keeping the existing negative lookahead logic.

In `@en/docs/administer/role-based-access-control.md`:
- Line 24: Rewrite the sentence in step 4 to produce a single clear instruction:
replace the two clauses "And select the scopes..." and "For example, If..." with
one flowing sentence that instructs the user to choose "Custom scope
assignments" in the "Select Permissions" menu and then pick the desired scopes,
and include the example scopes `apim:keymanagers_manage`, `apim:tenantInfo`, and
`apim:admin_settings` as a concrete example; ensure "If" is lowercased and
remove the leading "And" so the sentence reads smoothly.

In
`@en/docs/install-and-setup/setup/distributed-deployment/configuring-apim-as-a-gateway.md`:
- Line 35: The phrase "with regards to trying out" in the sentence "You can
refer to the [Quick Start
Guide](https://apk.docs.wso2.com/en/latest/get-started/quick-start-guide-with-cp/)
with regards to trying out API Control Plane with Kubernetes Gateway using
APIM-APK Agent." is grammatically awkward; replace it with a correct and simpler
wording such as "for trying out" or "to try out" so the sentence reads e.g. "You
can refer to the Quick Start Guide for trying out API Control Plane with
Kubernetes Gateway using APIM-APK Agent." Ensure the linked text remains
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17199077-efa8-47e2-8bef-56ace17bb52a

📥 Commits

Reviewing files that changed from the base of the PR and between 3b8c7f3 and 44b3e13.

📒 Files selected for processing (3)
  • .github/workflows/alt-text-check.yml
  • en/docs/administer/role-based-access-control.md
  • en/docs/install-and-setup/setup/distributed-deployment/configuring-apim-as-a-gateway.md

# Find markdown images with empty alt: ![](path) or ![ ](path)
md_empty_alt=$(git grep -n -E "!\[\s*\]\([^)]*\)" -- 'en/**/*.md' || true)
# Find HTML <img> tags missing an alt attribute
html_missing_alt=$(git grep -n -P "<img\b(?![^>]*\balt=)[^>]*>" -- 'en/**/*.md' || true)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat >/tmp/alt_text_samples.md <<'EOF'
<img src="a.png">
<img data-alt="decorative" src="b.png">
<IMG SRC="c.png">
<img alt="ok" src="d.png">
EOF

echo "Current pattern:"
grep -nP "<img\b(?![^>]*\balt=)[^>]*>" /tmp/alt_text_samples.md || true

echo "Proposed pattern:"
grep -nP "(?i)<img\b(?![^>]*\salt\s*=)[^>]*>" /tmp/alt_text_samples.md || true

Repository: wso2/docs-apim

Length of output: 195


🏁 Script executed:

cat -n .github/workflows/alt-text-check.yml | head -30

Repository: wso2/docs-apim

Length of output: 1148


🏁 Script executed:

# Verify the exact pattern on line 18
sed -n '18p' .github/workflows/alt-text-check.yml

Repository: wso2/docs-apim

Length of output: 157


🏁 Script executed:

# Test additional edge cases for the proposed pattern
cat >/tmp/alt_text_extended.md <<'EOF'
<img src="a.png">
<img data-alt="decorative" src="b.png">
<IMG SRC="c.png">
<img alt="ok" src="d.png">
<img ALT="ok" src="e.png">
<img alt = "ok" src="f.png">
<img alt="" src="g.png">
<img data-alt="test" alt="ok" src="h.png">
<img src="i.png" data-alt="">
EOF

echo "=== Testing proposed pattern with edge cases ==="
grep -nP "(?i)<img\b(?![^>]*\salt\s*=)[^>]*>" /tmp/alt_text_extended.md || true

Repository: wso2/docs-apim

Length of output: 221


Tighten <img> regex to avoid false negatives.

The current pattern on line 18 misses two cases: HTML <img> tags in uppercase (e.g., <IMG>) due to case-sensitive matching, and attributes like data-alt= are incorrectly accepted as valid alt= attributes due to word-boundary matching.

Proposed fix
-          html_missing_alt=$(git grep -n -P "<img\b(?![^>]*\balt=)[^>]*>" -- 'en/**/*.md' || true)
+          html_missing_alt=$(git grep -n -P "(?i)<img\b(?![^>]*\salt\s*=)[^>]*>" -- 'en/**/*.md' || true)

The updated pattern uses (?i) for case-insensitive matching and \salt\s*= to require whitespace boundaries around alt=, preventing matches against data-alt= or similar attributes.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
html_missing_alt=$(git grep -n -P "<img\b(?![^>]*\balt=)[^>]*>" -- 'en/**/*.md' || true)
html_missing_alt=$(git grep -n -P "(?i)<img\b(?![^>]*\salt\s*=)[^>]*>" -- 'en/**/*.md' || true)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/alt-text-check.yml at line 18, The regex used to populate
html_missing_alt (the git grep pattern "<img\b(?![^>]*\balt=)[^>]*>") is too
permissive and case-sensitive; update the pattern used in html_missing_alt to
use case-insensitive matching and require a whitespace boundary around alt
(e.g., prefix with (?i) and replace \balt= with \salt\s*=) so it catches <IMG>
and avoids matching attributes like data-alt= while keeping the existing
negative lookahead logic.

2. Click `Scope Assignments` in the left sidebar and click on `Add scope mappings` .
3. In the `Provide role name` text input give the role name which was previously created in step 1 and then click `next`.
4. In the `Select Permissions` menu, select the `Custom scope assignments` option. And select the scopes that you want to assign for the newly created role. You can refer the following table when assigning the scopes. For example, If the admin wants the newly created user to access the key managers settings in the admin portal he can assign `apim:keymanagers_manage`, `apim:tenantInfo`, and `apim:admin_settings`.
4. In the `Select Permissions` menu, select the `Custom scope assignments` option. And select the scopes that you want to assign for the newly created role. You can refer to the following table when assigning the scopes. For example, If the admin wants the newly created user to access the key managers settings in the admin portal he can assign `apim:keymanagers_manage`, `apim:tenantInfo`, and `apim:admin_settings`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten wording for readability in this instruction step.

This sentence is grammatically awkward in two places ("And select...", "For example, If..."). Please rewrite it as one clear flow to improve documentation quality.

Suggested rewrite
-4. In the `Select Permissions` menu, select the `Custom scope assignments` option. And select the scopes that you want to assign for the newly created role. You can refer to the following table when assigning the scopes. For example, If the admin wants the newly created user to access the key managers settings in the admin portal he can assign `apim:keymanagers_manage`, `apim:tenantInfo`, and `apim:admin_settings`.
+4. In the `Select Permissions` menu, select `Custom scope assignments`, then choose the scopes to assign to the newly created role. Refer to the following table when assigning scopes. For example, if the admin wants the newly created user to access Key Manager settings in the Admin Portal, assign `apim:keymanagers_manage`, `apim:tenantInfo`, and `apim:admin_settings`.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
4. In the `Select Permissions` menu, select the `Custom scope assignments` option. And select the scopes that you want to assign for the newly created role. You can refer to the following table when assigning the scopes. For example, If the admin wants the newly created user to access the key managers settings in the admin portal he can assign `apim:keymanagers_manage`, `apim:tenantInfo`, and `apim:admin_settings`.
4. In the `Select Permissions` menu, select `Custom scope assignments`, then choose the scopes to assign to the newly created role. Refer to the following table when assigning scopes. For example, if the admin wants the newly created user to access Key Manager settings in the Admin Portal, assign `apim:keymanagers_manage`, `apim:tenantInfo`, and `apim:admin_settings`.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@en/docs/administer/role-based-access-control.md` at line 24, Rewrite the
sentence in step 4 to produce a single clear instruction: replace the two
clauses "And select the scopes..." and "For example, If..." with one flowing
sentence that instructs the user to choose "Custom scope assignments" in the
"Select Permissions" menu and then pick the desired scopes, and include the
example scopes `apim:keymanagers_manage`, `apim:tenantInfo`, and
`apim:admin_settings` as a concrete example; ensure "If" is lowercased and
remove the leading "And" so the sentence reads smoothly.

## Next Steps

You can refer the [Quick Start Guide](https://apk.docs.wso2.com/en/latest/get-started/quick-start-guide-with-cp/) with regards to trying out API Control Plane with Kubernetes Gateway using APIM-APK Agent.
You can refer to the [Quick Start Guide](https://apk.docs.wso2.com/en/latest/get-started/quick-start-guide-with-cp/) with regards to trying out API Control Plane with Kubernetes Gateway using APIM-APK Agent.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use “with regard to” (or simplify phrasing) for grammatical correctness.

with regards to trying out is awkward. Consider:
You can refer to the [Quick Start Guide](https://apk.docs.wso2.com/en/latest/get-started/quick-start-guide-with-cp/) for trying out API Control Plane with Kubernetes Gateway using APIM-APK Agent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@en/docs/install-and-setup/setup/distributed-deployment/configuring-apim-as-a-gateway.md`
at line 35, The phrase "with regards to trying out" in the sentence "You can
refer to the [Quick Start
Guide](https://apk.docs.wso2.com/en/latest/get-started/quick-start-guide-with-cp/)
with regards to trying out API Control Plane with Kubernetes Gateway using
APIM-APK Agent." is grammatically awkward; replace it with a correct and simpler
wording such as "for trying out" or "to try out" so the sentence reads e.g. "You
can refer to the Quick Start Guide for trying out API Control Plane with
Kubernetes Gateway using APIM-APK Agent." Ensure the linked text remains
unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants