DEV Community


Posted on • Updated on

Publish your blog articles everywhere with this github action

Long ago I made this comment in this article:

This is a really good idea with great potential. 
Imagine a standarized API for different blogs. 
You can automatize publishing and editing, multiple collaborators.
And use a git provider as unique source of content.

And you can also make your git repo as some sort of blog.
I'll use it for my next posts for sure.

Enter fullscreen mode Exit fullscreen mode

It was an idea that I had left on the back of my head and I didn't come back to it because I wasn't writing articles actively. But this has changed in the last months and I have published 6 articles during December. So I decided to revisit the idea and finally develop it.


blogpub is a github action developed with typescript with the purpose of allowing you to use a github repository as source of truth for your blog posts. The action supports:

  • Automatically publishing to Medium and
  • Templating
  • Metadata/config section (published, tags, title, etc)

In fact, this article was automatically published by blogpub and you can see it's source in this folder.

Template Support

Sometimes we want to add different content to our blog posts depending on the platform, for instance for I want to use liquid tags, which medium doesn't support.
For this purpose I have used handlebars to make use of conditionals. Example:

{{#if medium}}
This is only for Medium
{{#if devto}}
This is only for
Enter fullscreen mode Exit fullscreen mode

For the first release of the action, the template context contains:

  medium: boolean;
  devto: boolean;
Enter fullscreen mode Exit fullscreen mode

Article metadata

I have added support for a metadata section (similar to where we can specify the following attributes:

  • title: [string] The title of the article. If not specified, the first H1 heading will be used.
  • description: [string] Description for API.
  • tags: [string] Comma separated tags. Note: Medium allows up to 5 tags whereas only 4.
  • license: [string] Medium license type. Refer to Medium API Docs. Default: public-domain
  • published: [boolean]. Default: true


title: "First blogpub test"
tags: test, ci
# I'm using `blogpub`
Enter fullscreen mode Exit fullscreen mode

Adopting CI/CD practices for blogging

Imagine the following scenario:

  • Write an article
  • Create PR
  • CI checks the spelling
  • Your peers review the article and propose changes or approve it
  • Merge the PR to main and it gets published everywhere
  • Use send tweet action to promote your new article.

I can imagine this workflow in a company where different colleagues write articles together. I like the idea that we could also automatize tweets, this is why blogpub outputs the URLs of the article after publishing it.


Ideally you want to run this action for every push to your main branch. This setup should be enough.

name: 'publish'

      - 'main'
      - 'articles/*'
    name: publish new article
    runs-on: ubuntu-latest    
      - name: Checkout
        uses: actions/checkout@v2
      - name: blogpub
        uses: protiumx/blogpub@v0.2.3
          articles_folder: articles
          devto_api_key: ${{secrets.DEV}}
          gh_token: ${{secrets.GH}}
          medium_token: ${{secrets.MEDIUM}}
          medium_user_id: <user_id>
Enter fullscreen mode Exit fullscreen mode

Few things to take into account:

  • We only want to run the action for files inside a folder.
  • You need to setup repository secrets with your tokens and api keys.

Check this blog source to see this in action.

What is missing?

For the first release I just wanted to be able to publish the articles in Medium and But there are a few features that would be handy:

  • Uploading images: Imagine also versioning images and then uploading those images automatically
  • Support for updates: If you want to make a correction, it should be possible to update the source and it should get reflected in all the platform the article was published to.
  • Platform specific configuration: maybe we want different tags per platform
  • Support multiple articles: at the moment blogpub publishes only 1 article per run.

What else would you like to have? Let me know in the comments!

That's it!
As usual, any help is well received and I have a TODO list if you would like to collaborate with this project.

GitHub logo protiumx / blogpub

Github action to publish your blog articles from Markdown to Medium or



Github action to publish your blog articles to Medium or It gets the files from a push event and process the first md file that find The file is ignored if it already existed before the push event. This avoid publishing again when making fixes on an existing article.


In order to interact with both platforms API's you will need:


The action will grab an markdown file from a push event to a branch The following workflow configuration will publish articles that are committed to the main branch:

      - 'main'
      - 'articles/*'
Enter fullscreen mode Exit fullscreen mode

Note: we only want to trigger this action when files are added to the folder blogs.

You can define your job as follows:

Enter fullscreen mode Exit fullscreen mode


Latest comments (0)