Skip to content

leonmsaia/pr-runner

Repository files navigation

🎭 Playwright Runner API

Automated browser execution API powered by Playwright, Fastify, and Docker.
Ideal for remote automation, login handling, web scraping, and headless workflows—accessible via simple HTTP POST calls.


📦 Project Structure

.
├── Dockerfile
├── docker-compose.yml
├── example.env
├── .env               # Not committed (add secrets here)
├── package.json
├── runner.ts          # Fastify API entrypoint
├── tsconfig.json
├── scripts/           # All .tsx scripts are executed dynamically
│   └── login-demo.tsx # Example Playwright script

🚀 Getting Started

1. Clone the repo

git clone https://github.com/yourusername/playwright-runner.git
cd playwright-runner

2. Configure Environment

Create .env from example.env or edit it directly:

PLAYWRIGHT_PORT=7780
PLAYWRIGHT_HOST=0.0.0.0

🐳 Run with Docker

Ensure the external Docker network exists:

docker network create NETWORKNAME

Then build and start the container:

docker-compose up -d --build

The API will be available at:

http://localhost:7780/run

📡 API Usage

POST /run

Run a specific Playwright script via HTTP.

Headers:

Content-Type: application/json

Body (Example – login-demo.tsx):

{
  "script": "login-demo",
  "params": {
    "username": "tomsmith",
    "password": "SuperSecretPassword!"
  }
}

Response:

{
  "status": "ok",
  "message": "You logged into a secure area!",
  "loggedIn": true
}

🧠 Script Development

All scripts are stored in /scripts and executed with:

npx tsx scripts/<script>.tsx

Each script should accept params from the CLI:

const args = JSON.parse(process.argv[2] || '{}');

Example filename: scripts/login-demo.tsx
Use "script": "login-demo" to run it via API.


🛠 Tech Stack

  • Playwright for browser automation
  • Fastify for lightweight API
  • TypeScript with tsx runner
  • Docker for containerization

✍️ Author

Leon M. Saia
GitHub: @leonmsaia


⚠️ Disclaimer

This tool is intended for educational, automation, and internal use.
Do not use it to interact with external systems you don't own or have permission to automate.


📄 License

MIT – Free to use, modify, and distribute.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors