Skip to content

Commit 3c74f39

Browse files
committed
feat: Add optional 'session_state_path' input, and use it if provided.
1 parent a98b327 commit 3c74f39

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

.github/actions/find/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ https://primer.style
1515
https://primer.style/octicons/
1616
```
1717

18+
#### `session_state_path`
19+
20+
**Optional** Path to a file containing authenticated session state.
21+
1822
### Outputs
1923

2024
#### `findings`

.github/actions/find/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ inputs:
66
description: "Newline-delimited list of URLs to check for accessibility issues"
77
required: true
88
multiline: true
9+
session_state_path:
10+
description: "Path to a file containing authenticated session state"
11+
required: false
912

1013
outputs:
1114
findings:

.github/actions/find/src/findForUrl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import type { Finding } from './types.d.js';
22
import AxeBuilder from '@axe-core/playwright'
33
import playwright from 'playwright';
44

5-
export async function findForUrl(url: string): Promise<Finding[]> {
5+
export async function findForUrl(url: string, sessionStatePath?: string): Promise<Finding[]> {
66
const browser = await playwright.chromium.launch({ headless: true, executablePath: process.env.CI ? '/usr/bin/google-chrome' : undefined });
7-
const context = await browser.newContext();
7+
const context = await browser.newContext({ storageState: sessionStatePath });
88
const page = await context.newPage();
99
await page.goto(url);
10-
10+
1111
let findings: Finding[] = [];
1212
try {
1313
const rawFindings = await new AxeBuilder({ page }).analyze();

.github/actions/find/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ export default async function () {
55
core.info("Starting 'find' action");
66
const urls = core.getMultilineInput('urls', { required: true });
77
core.debug(`Input: 'urls: ${JSON.stringify(urls)}'`);
8+
const sessionStatePath = core.getInput('session_state_path', { required: false });
9+
core.debug(`Input: 'session_state_path: ${sessionStatePath}'`);
810

911
let findings = [];
1012
for (const url of urls) {
1113
core.info(`Scanning ${url}`)
12-
const findingsForUrl = await findForUrl(url);
14+
const findingsForUrl = await findForUrl(url, sessionStatePath);
1315
if (findingsForUrl.length === 0) {
1416
core.info(`No accessibility gaps were found on ${url}`);
1517
continue;

0 commit comments

Comments
 (0)