This GitHub Action scans images added, changed, or updated as part of a Pull Request (including images referenced in the PR body) and runs colorblind vision simulations (Protanopia, Deuteranopia, Tritanopia) on them. It posts a textual report on the PR commenting whether the simulation succeeded, helping maintain color accessibility.
Important: To allow the action to comment on pull requests, add the following permissions block to your workflow:
permissions:
pull-requests: write
contents: readNote: This action currently only works on public repositories.
Add the action to your workflow triggered on pull requests. You must also set the following environment variables in your workflow step:
- name: Run Colorblind Snapshot Analyzer
uses: NotTheRealWallyx/colorblind-snapshot-analyzer@1.0.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}Full example:
name: Colorblind Accessibility Check
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: read
jobs:
colorblind-snapshot-analyzer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Colorblind Snapshot Analyzer
uses: NotTheRealWallyx/colorblind-snapshot-analyzer@1.0.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}| Name | Required | Description |
|---|---|---|
| repo-token | Yes | GitHub token to post comments and access PR files. Typically ${{ secrets.GITHUB_TOKEN }}. |
Posts a PR comment listing the images analyzed and simulation status for each colorblind type.
### 🎨 Colorblind Snapshot Report
**Note:** RMS diff measures the visual difference between the original and simulated image. A higher RMS diff means more difference (more visible change for colorblind users), while a lower value means less difference (potentially less colorblind-friendly).
**ColoredMap.png**:
- ✅ protanopia vision: Image is likely colorblind-friendly (RMS diff=45.70)
- ✅ deuteranopia vision: Image is likely colorblind-friendly (RMS diff=39.71)
- ⚠️ tritanopia vision: Image may NOT be colorblind-friendly (RMS diff=4.35)
**ColorBlindCircle.png**:
- ✅ protanopia vision: Image is likely colorblind-friendly (RMS diff=53.98)
- ✅ deuteranopia vision: Image is likely colorblind-friendly (RMS diff=42.69)
- ✅ tritanopia vision: Image is likely colorblind-friendly (RMS diff=43.96)
To set up locally:
poetry installTo run on a pull request (set environment variables as needed):
poetry run python -m colorblind_snapshot_analyzer.mainYou may need to set the following environment variables for local testing:
GITHUB_TOKEN(a GitHub personal access token)
To analyze all images in a local folder (default: images):
- Place your images in a folder named
images(or set theLOCAL_IMAGE_DIRenvironment variable to your folder). - Run:
poetry run python -m colorblind_snapshot_analyzer.localThis will print a colorblind accessibility report for all images in the folder.
Currently, this action only works on public repositories.
This is because the action is only able to retrieve images from pull requests in public repositories. For private repositories or PRs from forks, GitHub restricts access to certain resources and files, which prevents the action from analyzing images or posting comments. This is a known limitation and is being investigated for possible workarounds or future support.
- Make action work on private repositories
- Investigate adding use of better vision deficiency simulators to have a better benchmark on what colorblind friendly is
This project is licensed under the GNU GPL v3. © NotTheRealWallyx