A bot for 🐦 auto-posting to Reddit.
-
Clone the repository:
cd some/where git clone https://github.com/Ambratolm/reddit-poster.git cd reddit-poster
-
Install the dependencies:
npm i
-
Install Nodemon globally:
npm i -g nodemon
-
Run the bot for development:
npm run dev
💡 During development, the environment variables are automatically retrieved from the
.env
file and registred in theprocess.env
object for access in code.
💡 Use the provided.env-tmp
file as a reference to make your own personal.env
file.
💡 It is advised to not push the.env
file in production repository, because it contains sensible and confidential data. So, either delete it or add it to.gitignore
.
To deploy the project in a node environment:
-
Push the repository to a node production server using a service like Heroku.
💡 For Heroku, see: Deploying Node.js Apps on Heroku.
💡 As this is not an HTTP Web app, but more like a worker process, the service should be set to run it as worker process.
💡 To do it in Heroku, using the Heroku CLI, runheroku ps:scale web=0 worker=1 -a app-name
.
💡worker
corresponds to the name given in the Procfile file and can be renamed to anything (Unlikeweb
, which is reserved for the Web process only). -
Manually register the environment variables in the node production server.
💡 For Heroku, see: Configuration and Config Vars.
💡 To do it in Heroku, using the Heroku CLI, run
heroku config:set VARIABLE_NAME=value -a app-name
for every variable to add.
💡 Runheroku config -a app-name
to view all variables.💡 To do it in Heroku, using the Heroku Dashboard, go to the app's Settings / Config Vars.
-
Install the dependencies and Start the bot for production:
💡 In Heroku, this can be done automatically everytime after pushing the repository.
npm i && npm start
💡 In Heroku, to browse the deployed app files and folders, using the Heroku CLI, run
heroku run bash -a app-name
to access a terminal on the server.
💡 In the remote terminal, you can rundir
to display the current directory,cd dir-name
to change the directory, andcat file-name
to display the content of a text file. For more, see: Bash Shell Reference.
- Runtime: NodeJS
- Package Manager: NPM
- Editor: Sublime Text
- ⚛️ Core: NodeJS