Coder Social home page Coder Social logo

blog_poster's Introduction

Blog Poster

A ruby script that uses the Github API to create a pull request and then commit it. Used for github page hosted sites

It's intended to be run as a cron job once per day. It will get the branches from a specified repository and merge the branch that matches a template (the default looks like "Scheduled(2017-10-10)"). If that branch is found, it will create a pull request and then merge that pull request into the master branch for the pages repository.

Reasoning

I've gotten tired to trying to manage my posting schedule.

One of the problems with github pages is that if you have it configured to ignore future posts then Github will not rebuild them when that time arrives.

I've seen posts on how to do make it so the pages show up using zapier, but they require two different zaps, require a google calendar connection and if you change the format of the date, a paid subscription to zapier.

That's too much for me to swallow just to get pages to show up when they should.

So, this script was born. It can be scheduled using cron once a day. It connects to github using today's date, checks to see if there is a matching branch and merges the branch into master if it's there.

Finally, the default name you should have for the branches should follow this format: Scheduled(2019-01-30)

Requirements

This script requires ruby 2.4.0 to be installed along with with bundler gem.

Setup

  1. Clone the repository to a location on the computer that will be running the job every day.

    git clone https://github.com/digitalbias/blog_poster.git
  2. Install the ruby gems for the project

    bundle install
  3. Rename sample.env to .env

  4. Change the values in the new .env file. GITHUB_PASSWORD can be either an oauth token or your password. You can change BRANCH_NAME_TEMPLATE to whatever you would like. Also if you don't like the default format of %Y-%m-%d for the date, you can also update the date format.

    This makes it so you can have a completly different branch format the script looks at instead of Scheduled(2017-10-10)

  5. Change permissions on the blog_poster.rb file so it can be executed by your cron job.

  6. Set up cron job.

  7. Schedule posts to your hearts content.

blog_poster's People

Contributors

digitalbias avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.