diff --git a/.all-contributorsrc b/.all-contributorsrc index 12adb40..9f59a61 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -43,6 +43,16 @@ "doc", "infra" ] + }, + { + "login": "HonkingGoose", + "name": "HonkingGoose", + "avatar_url": "https://avatars.githubusercontent.com/u/34918129?v=4", + "profile": "https://github.com/HonkingGoose", + "contributions": [ + "doc", + "a11y" + ] } ], "contributorsPerLine": 7, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e63353b..0851c76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,12 @@ -name: Run unit tests -on: push - +name: CI +on: + push: + branches: ["main"] + workflow_dispatch: + pull_request: jobs: - accessibility_alt_text_bot: + tests: + name: Run unit tests runs-on: ubuntu-latest steps: - name: Checkout repo @@ -12,4 +16,3 @@ jobs: run: | ls ./test-flag-alt-text.sh - diff --git a/README.md b/README.md index 719aaf5..29acb6e 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,32 @@ # Accessibility-alt-text-bot -This action supports accessible content sharing on GitHub by leaving an automated reminder whenever an image is shared on a GitHub Issue, Pull request, or Discussion without meaningful alternative text (alt text). -Alternative text helps convey the context of the image to those who use assistive technologies such as a screen reader and removes accessibility barriers. +This action reminds users to add a meaningful alternative text to their images. +Alternative text helps users who rely on tools like screen readers, and lowers accessibility barriers. -For guidance on setting alternative text, see [Alternative text for images on Primer](https://primer.style/design/guides/accessibility/alternative-text-for-images). +The action can check: -Images on GitHub default to using the filename as alt text. This action flags when the alt text has not been updated from the default: +- Issue comments +- Issue descriptions +- Pull Request comments +- Pull Request descriptions +- Discussion comments +- Discussion descriptions + +To learn how to write good alternative text, read [Alternative text for images on Primer](https://primer.style/design/guides/accessibility/alternative-text-for-images). + +## Why you may need this action + +Images on GitHub default to using the filename as alt text. +This action flags when the alt text has not been updated from the default: Screenshot of an automated actions comment on a GitHub issue that says, 'Uh oh! @monalisa, the image you shared is missing helpful alt text...' and contains instructions for setting alt text -**Note**: Ordinarily, setting `alt=""` will mark images as decorative. However, GitHub currently renders all images as a link. To avoid rendering links with no names, we recommend always setting alt text on images in GitHub. +> **Note** +> Normally, setting `alt=""` marks images as decorative. But GitHub renders all images as a link. To avoid rendering links with no names, we recommend always setting alt text on images in GitHub. ## How to add this action to your repo -Copy this workflow into any repo you want the accessibility-alt-text-bot to run in. +Copy this workflow into any repo you want the `accessibility-alt-text-bot` to run in: ```yml name: Accessibility-alt-text-bot @@ -41,22 +54,24 @@ jobs: if: ${{ github.event.issue || github.event.pull_request || github.event.discussion }} steps: - name: Get action 'github/accessibility-alt-text-bot' - uses: github/accessibility-alt-text-bot + uses: github/accessibility-alt-text-bot@v1.2.0 # Set to latest ``` -### Action stability +### Pin the action's version for stability -To ensure you stay on a stable version of this action consider locking the action to a specific version. +We recommend you pin the action to a specific version. +This makes sure you stay on a stable version of this action. ```yml - uses: github/accessibility-alt-text-bot@v1.0.0 + uses: github/accessibility-alt-text-bot@v1.2.0 ``` Replace the ref value with any commit hash. ## License -This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE.txt) for the full terms. +This project is licensed under the terms of the MIT open source license. +Please read [the MIT license file](./LICENSE.txt) for the full terms. ## Maintainers @@ -68,7 +83,7 @@ TODO: Be explicit about support expectations. ## Acknowledgement -Please read [Contributing Guide](./CONTRIBUTING.md) for more information. +Please read our [Contributing Guide](./CONTRIBUTING.md) for more information. ## Contributors ✨ @@ -83,6 +98,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Katie Foster
Katie Foster

🤔 ️️️️♿️ Kendall Gassner
Kendall Gassner

💻 ️️️️♿️ 📖 🚇 Kate Higa
Kate Higa

💻 ️️️️♿️ 📖 🚇 + HonkingGoose
HonkingGoose

📖 @@ -92,4 +108,5 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. +Contributions of any kind welcome! diff --git a/action.yml b/action.yml index e2c6757..5a54ece 100644 --- a/action.yml +++ b/action.yml @@ -59,8 +59,8 @@ runs: Learn more about alt text at [Basic writing and formatting syntax: images on GitHub Docs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#images)." flag="$(flagAltText "$content")" - echo $flag - echo $type + echo "Detected bad alt text: ${flag}" + echo "Event type: $type" if [[ $flag = true ]]; then if [[ $type = pr_comment ]] || [[ $type = pr_description ]]; then diff --git a/flag-alt-text.sh b/flag-alt-text.sh index d9003fb..2eb16f4 100644 --- a/flag-alt-text.sh +++ b/flag-alt-text.sh @@ -1,13 +1,18 @@ #!/bin/bash flagAltText() { - markdownMacOsScreenshotRegex="^.*!\[(Clean|Screen) ?[S|s]hot [0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-9][0-9].*\].*$" - semanticMacOsScreenshotRegex="^.*' - # html - 'image' - 'Screen shot 2020-01-01 at 12.00.00.png' - 'Screen Shot 2020-01-01 at 12.00.00.png' - 'Screenshot 2020-01-01 at 12.00.00.png' - 'CleanShot 2020-01-01 @12x' + # markdown + '![Cleanshot 2020-01-01 at 12.00.00.png]' + '![Clean shot 2020-12-01 @12x]' + "![Clean shot 2020-12-01 @12x]" + "![Screen Shot 2020-01-01 at 12.00.00.png]" + "![Screenshot 2020-01-01 at 12.00.00.png]" + "![image]" + "![Image]" + "![]" + "Check this: ![Image]" + "My awesome ![image]" + 'Check this out: image' + # html + 'image' + '' + "" + "" + '' + '' + 'Screen shot 2020-01-01 at 12.00.00.png' + 'Screen Shot 2020-01-01 at 12.00.00.png' + 'Screenshot 2020-01-01 at 12.00.00.png' + 'CleanShot 2020-01-01 @12x' ) declare -a should_be_false=( - # markdown - "![Screenshot of the new GitHub home page]" - "![Screen shot of Submit button with updated color contrast.]" - "![Image of a cat]" - # html - 'Mona Lisa, the Octocat' - 'Screenshot of the new danger button with a dark red shade' - 'Clean shot of the scenery' + # markdown + "![Screenshot of the new GitHub home page]" + "![Screen shot of Submit button with updated color contrast.]" + "![Image of a cat]" + # html + 'Mona Lisa, the Octocat' + 'Mona Lisa, the Octocat' + 'Screenshot of the new danger button with a dark red shade' + 'Clean shot of the scenery' ) echo "******Expecting true:*******" -for i in "${should_be_true[@]}" -do - echo "Testing: $i" - assert_true "$(flagAltText "$i")" "$i must be true" +for i in "${should_be_true[@]}"; do + echo "Testing: $i" + assert_true "$(flagAltText "$i")" "$i must be true" + if [ $? == 1 ]; then + exit 1 + fi done echo "******Expecting false:*******" -for i in "${should_be_false[@]}" -do - echo "Testing: $i" - assert_false "$(flagAltText "$i")" "$i must be false" +for i in "${should_be_false[@]}"; do + echo "Testing: $i" + assert_false "$(flagAltText "$i")" "$i must be false" + if [ $? == 1 ]; then + exit 1 + fi done -