Skip to content
2 changes: 2 additions & 0 deletions .github/actions/find/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ inputs:
outputs:
findings:
description: "List of potential accessibility gaps, as stringified JSON"
page_content:
description: "Content of the scanned page"

runs:
using: "node24"
Expand Down
18 changes: 15 additions & 3 deletions .github/actions/find/src/findForUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ import AxeBuilder from '@axe-core/playwright'
import playwright from 'playwright';
import { AuthContext } from './AuthContext.js';

export async function findForUrl(url: string, authContext?: AuthContext): Promise<Finding[]> {
export async function findForUrl(url: string, authContext?: AuthContext) {
const browser = await playwright.chromium.launch({ headless: true, executablePath: process.env.CI ? '/usr/bin/google-chrome' : undefined });
const contextOptions = authContext?.toPlaywrightBrowserContextOptions() ?? {};
const context = await browser.newContext(contextOptions);
const page = await context.newPage();
await page.goto(url);
await page.goto(url, {
waitUntil: 'load',
// - looks like default timeout is 3000ms
// - increasing for testing
timeout: 60000,
});

console.log('*** page content');
const content = await page.content();
console.log(content);

console.log(`Scanning ${page.url()}`);

let findings: Finding[] = [];
try {
const rawFindings = await new AxeBuilder({ page }).analyze();
console.log('*** RAW FINDINGS KEYS', Object.keys(rawFindings));
console.log('*** RAW FINDINGS', JSON.stringify(rawFindings.violations, null, 2));
findings = rawFindings.violations.map(violation => ({
scannerType: 'axe',
url,
Expand All @@ -29,5 +41,5 @@ export async function findForUrl(url: string, authContext?: AuthContext): Promis
}
await context.close();
await browser.close();
return findings;
return { findings, content};
}
3 changes: 2 additions & 1 deletion .github/actions/find/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default async function () {
let findings = [];
for (const url of urls) {
core.info(`Preparing to scan ${url}`);
const findingsForUrl = await findForUrl(url, authContext);
const { findings: findingsForUrl, content } = await findForUrl(url, authContext);
core.setOutput("page_content", content);
if (findingsForUrl.length === 0) {
core.info(`No accessibility gaps were found on ${url}`);
continue;
Expand Down