Skip to content

Commit ba75365

Browse files
authored
chore: Prepare for v1.4.0 (#1733)
2 parents 8d96292 + e95694d commit ba75365

33 files changed

+890
-263
lines changed

.github/actions/auth/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# auth
2+
3+
Authenticate with Playwright and save session state. Supports HTTP Basic and form authentication.
4+
5+
## Usage
6+
7+
### Inputs
8+
9+
#### `login_url`
10+
11+
**Required** Login page URL. For example, `https://github.com/login`
12+
13+
#### `username`
14+
15+
**Required** Username.
16+
17+
#### `password`
18+
19+
**Required** Password.
20+
21+
> [!IMPORTANT]
22+
> Don’t put passwords in your workflow as plain text; instead reference a [repository secret](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-a-repository).
23+
24+
### Outputs
25+
26+
#### `auth_context`
27+
28+
Stringified JSON object containing `username`, `password`, `cookies`, and/or `localStorage` from an authenticated session. For example: `{"username":"some-user","password":"correct-horse-battery-staple","cookies":[{"name":"theme-preference","value":"light","domain":"primer.style","path":"/"}],"localStorage":{"https://primer.style":{"theme-preference":"light"}}}`

.github/actions/auth/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Auth"
2+
description: "Authenticate with Playwright and save session state. Supports HTTP Basic and form authentication."
3+
4+
inputs:
5+
login_url:
6+
description: "Login page URL"
7+
required: true
8+
username:
9+
description: "Username"
10+
required: true
11+
password:
12+
description: "Password"
13+
required: true
14+
15+
outputs:
16+
auth_context:
17+
description: "Stringified JSON object containing 'username', 'password', 'cookies', and/or 'localStorage' from an authenticated session"
18+
19+
runs:
20+
using: "node20"
21+
main: "bootstrap.js"
22+
23+
branding:
24+
icon: "lock"
25+
color: "blue"

.github/actions/auth/bootstrap.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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, { quiet = false, ...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+
if (!quiet) {
14+
console.log(data)
15+
}
16+
})
17+
proc.stderr.setEncoding('utf8')
18+
proc.stderr.on('data', (data) => {
19+
console.error(data)
20+
})
21+
proc.on('close', (code) => {
22+
if (code !== 0) {
23+
reject(code)
24+
} else {
25+
resolve(code)
26+
}
27+
})
28+
})
29+
}
30+
31+
await (async () => {
32+
// If dependencies are not vendored-in, install them at runtime.
33+
try {
34+
await fs.accessSync(
35+
url.fileURLToPath(new URL('./node_modules', import.meta.url)),
36+
fs.constants.R_OK
37+
)
38+
} catch {
39+
try {
40+
await spawnPromisified('npm', ['ci'], {
41+
cwd: url.fileURLToPath(new URL('.', import.meta.url)),
42+
quiet: true
43+
})
44+
} catch {
45+
process.exit(1)
46+
}
47+
} finally {
48+
// Compile TypeScript.
49+
try {
50+
await spawnPromisified('npm', ['run', 'build'], {
51+
cwd: url.fileURLToPath(new URL('.', import.meta.url)),
52+
quiet: true
53+
})
54+
} catch {
55+
process.exit(1)
56+
}
57+
// Run the main script.
58+
const action = await import('./dist/index.js')
59+
await action.default()
60+
}
61+
})()

.github/actions/auth/package-lock.json

Lines changed: 161 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/auth/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "auth",
3+
"version": "1.0.0",
4+
"description": "Authenticate with Playwright and save session state. Supports HTTP Basic and form authentication.",
5+
"main": "dist/index.js",
6+
"module": "dist/index.js",
7+
"scripts": {
8+
"start": "node bootstrap.js",
9+
"build": "tsc"
10+
},
11+
"keywords": [],
12+
"author": "GitHub",
13+
"license": "MIT",
14+
"type": "module",
15+
"dependencies": {
16+
"@actions/core": "^1.11.1",
17+
"playwright": "^1.56.0"
18+
},
19+
"devDependencies": {
20+
"@types/node": "^24.7.0",
21+
"typescript": "^5.9.3"
22+
}
23+
}

0 commit comments

Comments
 (0)