# gh-auto-follow
Automatically follow back your GitHub followers using GitHub Actions + Python.
- Fork this repository.
- Go to Settings → Secrets → Actions and add:
GH_TOKEN→ Personal Access Token (scope:user:follow,read:user)GH_USERNAME→ Your GitHub username
- Commit changes and let GitHub Actions run automatically every 6 hours.
- Fetches your followers
- Checks who you already follow
- Follows back any new users automatically
- Python 3.10+
- PyGithub
- GitHub Actions
Token should not have repo or admin scopes — only:
read:useruser:follow
Actions are read-only except the follow/unfollow operations.
- Visit: https://github.com/settings/tokens
- You’ll see two sections:
- Fine-grained tokens (newer)
- Personal access tokens (classic)
- ✅ For this project, use the classic type because it’s simpler for user actions.
- Click “Generate new token (classic)”
Fill the form like this:
| Field | What to Choose |
|---|---|
| Note | gh-auto-follow bot |
| Expiration | No expiration (or 90 days if you prefer) |
| Select scopes | ✅ read:user✅ user:follow |
Leave everything else unchecked — don’t give repo/admin rights.
Click “Generate token”.
You’ll see a long key like: ghp_ABC123xyz...somethinglong
- Go to your repository → Settings → Secrets and variables → Actions
- Click “New repository secret”
- Add:
| Name | Value |
|---|---|
| GH_TOKEN | (paste your token here) |
| GH_USERNAME | your GitHub username |
✅ Done! Secrets are now securely stored.
-
Go to the Actions tab in your repository: https://github.com/ //actions
-
Click on the “Auto Follow Back” workflow.
-
Click “Run workflow” (top right)
-
Choose the main branch → click Run workflow.
💥 GitHub will spin up a container and execute your Python script.
The workflow runs automatically based on the cron schedule in: .github/workflows/auto_follow.yml
- Example:
"*/1 * * * *"→ every 1 minute - You can change it to run hourly or daily if preferred.
- Automatically follows new followers
- Unfollows users who unfollow you
- Can be scheduled via GitHub Actions
- Fully secure — token only has minimal required scopes
If you want to follow a user even if they don’t follow you, we need to change the logic:
Keep a list of “people I want to follow” in the script (hardcoded, in a file, or via a GitHub secret).
During each run, the script will:
Follow all new followers (mutual follow logic)
Follow people in your “favorites” list, even if they don’t follow you
This is separate from cron. Cron just determines how often the script checks GitHub and executes the follow/unfollow logic.
✅ How It Would Look in Code (Conceptually)
-
existing mutual-follow logic
to_follow = followers - following -
additional: people you want to follow no matter what
favorite_users = ["user1", "user2", "user3"]
to_follow += [u for u in favorite_users if u not in following]
- then follow all in to_follow
follow_user(token, user) ```
Thanks You