How to Enable Auto-Posting to Social Media
How to Enable Auto-Posting to Social Media
This guide explains how to get the necessary API keys for X (Twitter), LinkedIn, and Reddit, and how to set them up in your GitHub repository to enable automated posting when you publish a new blog post.
1. Get API Keys
š¦ X (Twitter)
Note: You need a Developer Account. The free tier allows 1,500 posts/month.
- Go to the X Developer Portal.
- Sign up for a Free developer account if you havenāt already.
- Create a new Project and App.
- Navigate to Keys and Tokens.
- Generate the following and save them immediately:
API Key(Consumer Key)API Key Secret(Consumer Secret)Access TokenAccess Token Secret
- Important: Ensure your App has Read and Write permissions. Go to āUser authentication settingsā, enable OAuth 1.0a, and switch permissions to āRead and Writeā. Regenerate tokens if you change permissions.
š¼ LinkedIn
- Go to LinkedIn Developers.
- Click Create App. Associate it with your Company Page (or create a dummy one if posting to personal profile basically works via the same API, but officially usually requires a page context for easiest automation).
- Under the Products tab, request access to Share on LinkedIn (or Sign In with LinkedIn + Share on LinkedIn).
- Go to Auth tab.
- Note down:
Client IDClient Secret
- Token Note: LinkedIn Access Tokens expire (usually 60 days). For mostly hands-off automation, you might need a workflow that refreshes them, or manually update the secret every 2 months.
š¤ Reddit
- Go to Reddit App Preferences.
- Click Create another app⦠(bottom of page).
- Select script.
- Fill in details (redirect uri can be
http://localhost:8080). - Click create app.
- Note down:
Client ID(the string under the app name)Client SecretUsername(your reddit username)Password(your reddit password)
2. Add Secrets to GitHub
- Go to your GitHub Repository.
- Click Settings > Secrets and variables > Actions.
- Click New repository secret.
-
Add the following secrets matching your keys:
Twitter:
TWITTER_CONSUMER_KEYTWITTER_CONSUMER_SECRETTWITTER_ACCESS_TOKENTWITTER_ACCESS_TOKEN_SECRET
LinkedIn:
LINKEDIN_ACCESS_TOKEN(You need to generate this using your Client ID/Secret via a tool like Postman standard OAuth2 flow, or use a specific GitHub Action that simplifies this).
Reddit:
REDDIT_CLIENT_IDREDDIT_CLIENT_SECRETREDDIT_USERNAMEREDDIT_PASSWORDREDDIT_SUBREDDIT(Target subreddit, e.g.,technologyor your own profileu_yourname)
3. Enable the Workflow
Once the secrets are added, uncomment the relevant sections in .github/workflows/distribute.yml.