Skip to content

Commit 913e6ed

Browse files
authored
feat: Initial commit (#1)
I verified that this branch’s code works: - Workflow file: https://github.com/github/accessibility-sandbox/blob/d10b6f3690948ccd65f44f209fdc453564132db1/.github/workflows/continuous-accessibility-scanner.yml (Hubber access only) - Successful workflow run: https://github.com/github/accessibility-sandbox/actions/runs/16604894366 (Hubber access only)
2 parents a29dd72 + 0d1c7db commit 913e6ed

File tree

13 files changed

+633
-2
lines changed

13 files changed

+633
-2
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @github/accessibility-reviewers

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
node_modules
3+
test-results

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# automated-a11y-scanning
2-
To be transferred/customer-facing: sharing our a11y automation with the world
1+
# continuous-accessibility-scanner
2+
3+
Finds potential accessibility gaps, files GitHub issues to track them, and attempts to fix them with Copilot.
4+
5+
## Usage
6+
7+
### Inputs
8+
9+
#### `urls`
10+
11+
**Required** Newline-delimited list of URLs to check for accessibility issues. For example:
12+
13+
```txt
14+
https://primer.style
15+
https://primer.style/octicons/
16+
```
17+
18+
#### `repository`
19+
20+
**Required** Repository (with owner) to file issues in. For example: `primer/primer-docs`.
21+
22+
#### `token`
23+
24+
**Required** Personal access token (PAT) with fine-grained permissions 'issues: write' and 'pull_requests: write'.
25+
26+
### Example workflow
27+
28+
```YAML
29+
name: Continuous Accessibility Scanner
30+
on: workflow_dispatch
31+
32+
jobs:
33+
continuous_accessibility_scanner:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: github/continuous-accessibility-scanner@main
37+
with:
38+
urls: |
39+
https://primer.style/octicons/
40+
repository: github/accessibility-sandbox
41+
token: ${{ secrets.GH_TOKEN }}
42+
```

action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "continuous-accessibility-scanner"
2+
description: "Finds potential accessibility gaps, files GitHub issues to track them, and attempts to fix them with Copilot."
3+
4+
inputs:
5+
urls:
6+
description: "Newline-delimited list of URLs to check for accessibility issues"
7+
required: true
8+
multiline: true
9+
repository:
10+
description: "Repository (with owner) to file issues in"
11+
required: true
12+
token:
13+
description: "Personal access token (PAT) with fine-grained permissions 'issues: write' and 'pull_requests: write'"
14+
required: true
15+
16+
runs:
17+
using: "node20"
18+
main: "bootstrap.js"
19+
20+
branding:
21+
icon: "compass"
22+
color: "blue"

bootstrap.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env node
2+
//@ts-check
3+
4+
import fs from 'node:fs'
5+
import * as url from 'node:url'
6+
import { spawn } from 'node:child_process'
7+
8+
function spawnPromisified(command, args, options) {
9+
return new Promise((resolve, reject) => {
10+
const proc = spawn(command, args, options)
11+
proc.stdout.setEncoding('utf8')
12+
proc.stdout.on('data', (data) => {
13+
console.log(data)
14+
})
15+
proc.stderr.setEncoding('utf8')
16+
proc.stderr.on('data', (data) => {
17+
console.error(data)
18+
})
19+
proc.on('close', (code) => {
20+
if (code !== 0) {
21+
reject(code)
22+
} else {
23+
resolve(code)
24+
}
25+
})
26+
})
27+
}
28+
29+
await (async () => {
30+
// If dependencies are not vendored-in, install them at runtime.
31+
try {
32+
await fs.accessSync(
33+
url.fileURLToPath(new URL('./node_modules', import.meta.url)),
34+
fs.constants.R_OK
35+
)
36+
} catch {
37+
try {
38+
await spawnPromisified('npm', ['ci'], {
39+
cwd: url.fileURLToPath(new URL('.', import.meta.url))
40+
})
41+
} catch {
42+
process.exit(1)
43+
}
44+
} finally {
45+
// Compile TypeScript.
46+
try {
47+
await spawnPromisified('npm', ['run', 'build'], {
48+
cwd: url.fileURLToPath(new URL('.', import.meta.url))
49+
})
50+
} catch {
51+
process.exit(1)
52+
}
53+
// Run the main script.
54+
const action = await import('./dist/index.js')
55+
await action.default()
56+
}
57+
})()

0 commit comments

Comments
 (0)