A small automation script for GitHub follow/unfollow that I built because I'm too lazy to do this manually.
This application runs on AWS Serverless components on a configurable schedule (e.g. once a day).
Cost stays within the AWS Free Tier under typical usage (no additional costs).
When you have many followers, processing them synchronously takes a long time, so the script is written using aiohttp and coroutines to run requests asynchronously.
git clone https://github.com/Scanf-s/aws-github-auto-follow.git- For simplicity, you can attach the Administrator role to your IAM user.
make buildsam deploy --guided--guided will prompt you for the following. The values are saved to samconfig.toml, so subsequent deploys do not need them again.
| Prompt | Description | Example |
|---|---|---|
Stack Name |
CloudFormation stack name (any unique name within the account/region) | github-autofollow |
AWS Region |
Region to deploy to | ap-northeast-2 |
Parameter LambdaFunctionName |
Lambda function name | GithubAutoFollowLambda |
Parameter GithubUsername |
Your GitHub username | blabla |
Parameter GithubToken |
GitHub Personal Access Token (user:follow, read:user scopes) |
ghp_xxx... |
Parameter GithubApiUrl |
GitHub API endpoint (press Enter to use the default) | https://api.github.com |
Parameter ScheduleExpression |
EventBridge schedule (rate or cron) — see section 6 | rate(3 hours) |
Confirm changes before deploy |
Review changesets before applying | Y/N |
Allow SAM CLI IAM role creation |
Required for the Lambda execution role | Y/N |
Save arguments to configuration file |
Save answers to samconfig.toml |
Y/N |
You can just press Enter to accept the defaults for any other prompts.
make build
sam deployThe Lambda is triggered by an EventBridge rule defined via the ScheduleExpression parameter in template.yml. You can change it without editing the template by passing a parameter override.
Supported expression formats (see AWS docs):
rate(N minutes|hours|days)— fixed interval. e.g.rate(1 hour),rate(1 day)cron(min hour day month day-of-week year)— UTC, 6 fields. One ofday/day-of-weekmust be?. e.g.cron(0 0 * * ? *)runs daily at 00:00 UTC (09:00 KST)
Update only the schedule on an existing stack:
sam deploy \
--parameter-overrides ScheduleExpression="rate(1 day)"Or edit samconfig.toml (parameter_overrides) so the new value persists across future deploys.
- Python 3.12 or later
- uv (recommended) or pip
Copy .env.example to .env and fill in the values.
cp .env.example .envYou can issue a GitHub Personal Access Token here. The required scopes are user:follow and read:user.
uv sync
uv run python main.pypython -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
python main.pyWhen executed, the script performs the following actions on the current account:
- Users who follow you but you do not follow back → follow
- Users you follow but who do not follow you → unfollow
--dry-run: List the target users without making any actual changes--concurrency N: Number of concurrent API requests (default: 5)
uv run python main.py --dry-run
uv run python main.py --concurrency 10CONCURRENCY: Number of concurrent requests (CLI flag takes precedence)EXCLUDE_FOLLOW: Comma-separated list of users to skip when followingEXCLUDE_UNFOLLOW: Comma-separated list of users to skip when unfollowingDRY_RUN: Run in dry-run mode on Lambda (1/true)
uv run pytest