Skip to content

Commit 86e6d3f

Browse files
committed
feat: Add 'Auth' action
1 parent be54bcc commit 86e6d3f

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import playwright from 'playwright';
44

55
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({ storageState: sessionStatePath });
7+
const context = await browser.newContext({ storageState: !!sessionStatePath ? sessionStatePath : undefined });
88
const page = await context.newPage();
99
await page.goto(url);
1010

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,22 @@ Trigger the workflow manually or automatically based on your configuration. The
9797
| `repository` | Yes | Repository (with owner) for issues and PRs | `primer/primer-docs` |
9898
| `token` | Yes | PAT with write permissions (see above) | `${{ secrets.GH_TOKEN }}` |
9999
| `cache_key` | No | Custom key for caching findings across runs<br>Allowed: `A-Za-z0-9._/-` | `cached_findings-main-primer.style.json` |
100-
| `session_state_path` | No | Path to a file containing authenticated session state | `/tmp/.auth/12345678/sessionState.json` |
100+
| `login_url` | No | If scanned pages require authentication, the URL of the login page | `https://github.com/login` |
101+
| `username` | No | If scanned pages require authentication, the username to use for login | `some-user` |
102+
| `password` | No | If scanned pages require authentication, the password to use for login | `correct-horse-battery-staple` |
103+
| `session_state_path` | No | If scanned pages require authentication, the path to a file containing authenticated session state | `/tmp/.auth/12345678/sessionState.json` |
101104
| `skip_copilot_assignment` | No | Whether to skip assigning filed issues to Copilot | `true` |
102105

103106
---
104107

108+
## Authentication
109+
110+
If access to a page requires logging-in first, and logging-in requires only a username and password, then provide the `login_url`, `username`, and `password` inputs.
111+
112+
If your login flow is more complex—if it requires two-factor authentication, single sign-on, passkeys, etc.–and you have a custom action that [authenticates with Playwright](https://playwright.dev/docs/auth) and persists authenticated session state to a file, then provide the `session_state_path` input. (If `session_state_path` is provided, `login_url`, `username`, and `password` will be ignored.)
113+
114+
---
115+
105116
## Configuring Copilot
106117

107118
The a11y scanner leverages Copilot coding agent, which can be configured with custom instructions:
@@ -119,4 +130,4 @@ Beta participants have direct contact for questions and suggestions. A public fe
119130

120131
---
121132

122-
*Last updated: 2025-09-25*
133+
*Last updated: 2025-10-01*

action.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ inputs:
1515
cache_key:
1616
description: "Custom key for caching findings across runs"
1717
required: false
18+
login_url:
19+
description: "If scanned pages require authentication, the URL of the login page"
20+
required: false
21+
username:
22+
description: "If scanned pages require authentication, the username to use for login"
23+
required: false
24+
password:
25+
description: "If scanned pages require authentication, the password to use for login"
26+
required: false
1827
session_state_path:
19-
description: "Path to a file containing authenticated session state"
28+
description: "If scanned pages require authentication, the path to a file containing authenticated session state"
2029
required: false
2130
skip_copilot_assignment:
2231
description: "Whether to skip assigning filed issues to Copilot"
@@ -42,12 +51,20 @@ runs:
4251
with:
4352
key: ${{ steps.cache_key.outputs.cache_key }}
4453
token: ${{ inputs.token }}
54+
- if: ${{ inputs.login_url && inputs.username && inputs.password && !inputs.session_state_path }}
55+
name: Authenticate
56+
id: auth
57+
uses: ./.github/actions/auth
58+
with:
59+
login_url: ${{ inputs.login_url }}
60+
username: ${{ inputs.username }}
61+
password: ${{ inputs.password }}
4562
- name: Find
4663
id: find
4764
uses: ./.github/actions/find
4865
with:
4966
urls: ${{ inputs.urls }}
50-
session_state_path: ${{ inputs.session_state_path }}
67+
session_state_path: ${{ inputs.session_state_path || steps.auth.outputs.session_state_path }}
5168
- name: File
5269
id: file
5370
uses: ./.github/actions/file

0 commit comments

Comments
 (0)