website-change-monitor
A GitHub Actions-powered service that monitors websites for changes using AWS DynamoDB for state tracking and creates GitHub issues when changes are detected.
Features
- ๐ Automated Monitoring: Runs every hour via GitHub Actions
- ๐ JavaScript Support: Uses Playwright to render JavaScript-heavy pages
- ๐ Flexible Detection:
- Checksum mode: Detect any content change
- Pattern mode: Detect specific text appearing or disappearing
- ๐พ State Persistence: AWS DynamoDB stores previous states
- ๐ Notifications: Creates GitHub issues when changes are detected
- โ๏ธ Secure AWS Integration: OIDC authentication (no stored credentials)
- ๐ ๏ธ Codespace Ready: Pre-configured development environment
Setup
Prerequisites
-
AWS Account with:
- DynamoDB access
- OIDC identity provider configured for GitHub Actions
- IAM role for GitHub Actions with DynamoDB permissions
-
GitHub Repository Secrets:
AWS_ROLE_ARN: ARN of the IAM role to assumeAWS_REGION: AWS region (e.g.,us-east-1)DYNAMODB_TABLE_NAME: (Optional) Name of the DynamoDB table (defaults towebsite-change-monitor)
-
Codespace Secrets (for development):
AWS_SSO_PROFILE: Your AWS SSO profile nameAWS_SSO_ACCOUNT: Your AWS account IDAWS_SSO_ROLE_NAME: SSO role nameAWS_SSO_REGION: AWS regionAWS_SSO_START_URL: AWS SSO start URL
Configuration
Edit config.yml to define websites to monitor:
jobs:
# Checksum mode: Detects any content change
- jobname: example-website
url: https://example.com
# Pattern mode: Detects when specific text appears or disappears
- jobname: registration-check
url: https://my.raceresult.com/365611/registration
pattern: "100\\s+miles\\s+-\\s+waiting\\s+list\\s+0\\s+Available"
action: when-text-disappearsRequired fields:
jobname: Unique identifierurl: Website URL to monitor
Pattern mode fields:
pattern: Regular expression to search for (HTML tags are stripped before matching)action: When to trigger an alertwhen-text-disappears(default): Alert when pattern disappearswhen-text-appears: Alert when pattern appears
GitHub Secrets Setup
Configure secrets in your repository:
- Navigate to Settings โ Secrets and variables โ Actions
- Click New repository secret and add:
| Secret Name | Description | Example |
|---|---|---|
AWS_ROLE_ARN |
ARN of the IAM role for GitHub Actions | arn:aws:iam::123456789012:role/GitHubActionsRole |
AWS_REGION |
AWS region for DynamoDB | us-east-1 |
DYNAMODB_TABLE_NAME |
(Optional) DynamoDB table name | website-change-monitor |
Codespace Secrets (Optional)
For development in Codespaces:
- Navigate to User Settings โ Codespaces โ Secrets
- Add these secrets:
| Secret Name | Description | Example |
|---|---|---|
AWS_SSO_PROFILE |
Your AWS SSO profile name | codespace-sso |
AWS_SSO_ACCOUNT |
Your AWS account ID | 123456789012 |
AWS_SSO_ROLE_NAME |
SSO role name | AdministratorAccess |
AWS_SSO_REGION |
AWS region | us-east-1 |
AWS_SSO_START_URL |
AWS SSO start URL | https://d-xxxxxxxxxx.awsapps.com/start |
AWS IAM Role Setup
Step 1: Create OIDC Provider in AWS
If you haven't already set up GitHub Actions OIDC provider in your AWS account:
- Go to IAM โ Identity providers โ Add provider
- Select OpenID Connect
- Provider URL:
https://token.actions.githubusercontent.com - Audience:
sts.amazonaws.com - Click Add provider
Step 2: Create IAM Role
Create an IAM role with the following configuration:
Trust Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::YOUR_ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:YOUR_GITHUB_USERNAME/website-change-monitor:*"
}
}
}
]
}Permissions Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:CreateTable",
"dynamodb:DescribeTable",
"dynamodb:GetItem",
"dynamodb:PutItem"
],
"Resource": "arn:aws:dynamodb:*:*:table/website-change-monitor"
}
]
}Replace YOUR_ACCOUNT_ID and YOUR_GITHUB_USERNAME with your actual values.
Usage
Automatic Monitoring
The workflow runs every hour automatically. To trigger manually:
- Open the Actions tab
- Select Monitor Websites
- Click Run workflow
Local Testing
pip install -r requirements.txt
aws configure # or use AWS SSO
export DYNAMODB_TABLE_NAME=website-change-monitor
python monitor.pyHow It Works
- Load Configuration: Read website jobs from
config.yml - Fetch Content: Use Playwright to render the full page (including JavaScript)
- Detect Changes:
- Checksum Mode: Compute SHA-256 hash and compare with previous state
- Pattern Mode: Strip HTML tags, search for regex pattern, and trigger alerts based on action:
when-text-disappears: Alert when pattern disappearswhen-text-appears: Alert when pattern appears
- Compare State: Check against stored state in DynamoDB
- Create Alert: Generate GitHub issue for detected changes
- Update State: Store new checksum/pattern state in DynamoDB
Development
Using GitHub Codespaces
This repository is pre-configured for GitHub Codespaces with Python 3.12, AWS CLI, and all dependencies.
After opening a Codespace, authenticate with AWS SSO:
aws sso login --profile codespace-sso
aws sts get-caller-identity --profile codespace-sso # VerifyNote: Configure Codespace secrets before opening the Codespace. The
AWS_SSO_ROLE_NAMEmust match a role in your AWS IAM Identity Center.
Project Structure
.
โโโ .devcontainer/
โ โโโ devcontainer.json # Codespace configuration
โ โโโ postCreateCommand.sh # Setup script for Codespace
โโโ .github/
โ โโโ workflows/
โ โโโ monitor-websites.yml # GitHub Actions workflow
โโโ config.yml # Website monitoring configuration
โโโ monitor.py # Main monitoring script
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
DynamoDB Schema
| Attribute | Type | Description |
|---|---|---|
jobname |
String (PK) | Unique job identifier |
url |
String | Website URL |
checksum |
String | SHA-256 hash of last content |
datetime |
String | ISO 8601 timestamp |
pattern_found |
Boolean | Pattern state (pattern mode only) |
Troubleshooting
Table creation fails: Ensure IAM role has dynamodb:CreateTable permission.
Authentication errors: Verify OIDC provider, IAM trust policy, and repository secrets are configured correctly.
No changes detected: First run initializes state. Changes are detected on subsequent runs.
License
MIT