twitter-bot-action
                                
                                 twitter-bot-action copied to clipboard
                                
                                    twitter-bot-action copied to clipboard
                            
                            
                            
                        Github Action to run Twitter Bot
Twitter Bot Action
GitHub Action for running Twitter Bot
This is a GitHub Action that runs your twitter bot periodically without services like Heroku, Render and AWS.
Only JavaScript Supported
Setup
- 
Create a config.jsfile and export an object with the following.module.exports = { consumer_key: process.env.CONSUMER_KEY, consumer_secret: process.env.CONSUMER_SECRET, access_token: process.env.ACCESS_TOKEN, access_token_secret: process.env.ACCESS_TOKEN_SECRET, };
- 
Import config.jsinto your file and use for your bot configuration.const config = require('./config'); // Using Twitter library const Bot = new Twitter(config); // Using Twit library const Bot = new Twit(config);
- 
Create a twitter app with your shared twitter account and store the credentials as CONSUMER_KEY,CONSUMER_SECRET,ACCESS_TOKENandACCESS_TOKEN_SECRETin your repository’s secrets settings.
- 
Add a workflow file to your project (e.g. .github/workflows/build.yml) with this:name: Tweet on: workflow_dispatch: schedule: - cron: '*/30 * * * *' # Runs Bot every 30 minutes jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Use Node.js uses: actions/setup-node@v1 with: node-version: '12.x' - name: Run Bot uses: dephraiim/[email protected] env: CONSUMER_KEY: ${{ secrets.CONSUMER_KEY }} CONSUMER_SECRET: ${{ secrets.CONSUMER_SECRET }} ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
Tweeting
Using the workflow above, GitHub will run your twitter bot every 30 minutes.
Options
You can configure the action further with the following options:
- package_root: Directory where NPM/Yarn commands should be run (default:- ".")
- file_name: Name of the main bot file (default:- "index.js")
Development
Contributions and Suggestions are always welcome!
LICENSE
MIT