AutoPost is a powerful automation tool that brings life to your LinkedIn profile, without you lifting a finger. Using GitHub Actions, it schedules and publishes dynamic, human-like posts directly to LinkedIn and Twitter. The magic? It runs hourly at :47 (because no human posts on the hour, right?) and picks two random hours daily for actual LinkedIn content. All other times, your thoughts go to Twitter. Genius? Slightly.
- β
Human-Like Posting Times: Runs hourly at
:47and posts twice a day to LinkedIn at random hours (within 10 AM to 10 PM IST). - β Fallback to Twitter: Every other run posts to Twitter instead, keeping your brand alive and buzzing across platforms.
- β OAuth2 Authentication: Secure LinkedIn API integration.
- β AI-Powered Content Generation: Uses a custom prompt to generate text via the Gemini API.
- β Seamless Automation: Managed fully by GitHub Actions; set it and forget it.
-
Hourly Cron: A GitHub Actions workflow runs every hour at
:47UTC. -
Smart Random Logic:
- 2 out of 12 runs per day (randomized) are selected to post on LinkedIn.
- Other 10 runs default to Twitter.
-
AI Content: A Google Gemini model (via API key) is queried with your custom
PROMPTorPROMPT_Xto generate platform-specific posts. -
LinkedIn Posts:
- Posted via the
ugcPostsendpoint using your personal URN. - Public visibility.
- Posted via the
-
Twitter Posts:
- Posted via Twitter API v2 using Tweepy.
Before you deploy, make sure you have:
- Python 3.12+
- A LinkedIn Developer App with access token generation enabled
- A Twitter Developer App with API v2 access
- A GitHub repository
- GitHub Actions enabled
Set these in your GitHub repository's Settings > Secrets and variables > Actionsctions:
| Secret Name | Description |
|---|---|
GOOGLE_API_KEY |
Gemini AI API key (for content generation) |
LINKEDIN_ACCESS_TOKEN |
LinkedIn OAuth2 access token |
LINKEDIN_CLIENT_ID |
LinkedIn App client ID |
LINKEDIN_CLIENT_SECRET |
LinkedIn App client secret |
PROMPT |
Prompt for LinkedIn post generation |
PROMPT_X |
Prompt for Twitter post generation |
X_BEARER_TOKEN |
Twitter API bearer token |
X_API_KEY |
Twitter API key |
X_API_SECRET |
Twitter API secret |
X_ACCESS_TOKEN |
Twitter access token |
X_ACCESS_SECRET |
Twitter access token secret |
- Clone the repo:
git clone https://github.com/yourusername/LinkedIn-AutoPost.git
cd LinkedIn-AutoPost- Set your GitHub Secrets as described above.
- Ensure the
.github/workflows/main.ymlis present and set to run every hour at:47.
schedule:
- cron: '47 * * * *'- Push and let GitHub Actions take over.
-
main.pycontains the decision tree:- Every hour it checks if it's one of the 2 lucky LinkedIn posting hours.
- If yes, it posts to LinkedIn using Gemini-generated content.
- If not, it posts to Twitter using a separate prompt and set of API keys.
This mimics natural, non-robotic behavior; perfect for building trust with your audience.
You can optionally integrate Gmail or other services using the NOTIFICATION_EMAIL secret for updates after each post. This is currently a placeholder for future extensions.
- All tokens and secrets are stored in GitHub Secrets.
- Avoid hardcoding credentials.
- Logs only show non-sensitive data.
- Image + media support
- Auto-refresh for expired LinkedIn tokens
- Enhanced scheduling UI via GitHub Actions Dispatch
- Email summaries of posts made
- Post analytics
LinkedIn Prompt (PROMPT):
Write a professional, yet engaging post on emerging AI trends in 2025 for a tech-savvy audience.
Twitter Prompt (PROMPT_X):
Tweet a witty and insightful one-liner about how AI is rewriting the rules of productivity in 2025.
Want to test manually? Go to GitHub > Actions > Run workflowrkflow and manually trigger the cron workflow.
"Even bots need a personal brand."
This project doesnβt just automate posts; it mimics the unpredictability and style of human behavior. Build trust. Stay active. And do it while you sleep.
Built with β€οΈ by Satwik Bhusanur