Automate your DEV Posts using GitHub Actions
Tags: devto, publication, stackbit, github
Published: 2020-07-05 09:03:50

---
title: Automate your DEV Posts using GitHub Actions
published: true
description: In this tutorial you will learn how to set up a GitHub repository that automatically publishes selected posts to dev.to.
tags: devto, publication, stackbit, github
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/z9tyvxhhuhl3mhgg1pvx.png
canonical_url: https://beeman.dev/posts/automate-your-dev-posts-using-github-actions-4hp3
---

Over the last few days I've been working on getting [my website](https://beeman.dev) online. The most important part of my site is the blog, and my idea is that I cross-post[^1] my content between my website and DEV.

DEV makes this super easy as it [integrates](https://dev.to/settings/integrations) with [Stackbit](https://stackbit.com/). Within a few clicks I was up and running with a fresh GitHub repo containing a Gatsby app connected to Netlify for building and hosting.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mx7mf925iheuzj3yhk6l.png)

The build on Netlify happens in one of two occasions: when my content on DEV updates or when the GitHub repo updates.

With this setup in place I moved a lot of potential obstacles out of the way, there is very little for me to worry about. Most importantly though, I can manage a big part of my site using Git, which I love!

{% twitter 1279422434387640320 %}

After declaring my love to this amazingly easy to use stack on Twitter, I got a reply from [Maxime](https://dev.to/maxime1992). He told me about a tool he created to publish your blogs from GitHub to DEV, which means my I can manage my complete site using Git, even better!

{% twitter 1279504406162087937 %}

In [his post](https://dev.to/maxime1992/manage-your-dev-to-blog-posts-from-a-git-repo-and-use-continuous-deployment-to-auto-publish-update-them-143j) you can find the all the steps you need to set this up. The process is pretty straightforward and very well described. In the guide he explains how to use Travis CI to set up automatic publishing, but I'd rather use GitHub Actions.

In order to get started you need to finish the 2 steps of [Maxim's tutorial](https://dev.to/maxime1992/manage-your-dev-to-blog-posts-from-a-git-repo-and-use-continuous-deployment-to-auto-publish-update-them-143j) then come back here and continue below. I'll wait.

## 1. Set the DEV API Token in the repo settings.

Navigate to the `Settings` page of the repo and select `Secrets`.

Click `New Secret` and set the name to `DEV_TO_GIT_TOKEN` and paste the DEV API key in the value field, then click `Add Secret`.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fqdglbh4ys58g3qp7t8b.png)

## 2. Create the GitHub Actions Workflow file.

Create the file `.github/workflows/build.yml` and add this content:

{% gist https://gist.github.com/beeman/e8c56d6ec3339448be5ad167c10583f3 %}

## 3. That's it!

After your next push, GitHub picks up the workflow and starts executing it. You can follow the process in the Actions tab.

## Conclusion

Maxim's tool is an amazing addition to my publishing setup, which consists of a repo for my site and another for my content. I'll probably merge them at some point but at this moment I have bigger fish to fry.

I have created a small helper script that syncs content from DEV back my local repo, so I now have a full sync. This comes in handy after creating a new draft on DEV and allows you to make changes to the blog through their UI too.

I'm considering to wrap the syncing up in a tool that I can just run in the background while publishing, and I'd love to have a local preview of the blog that I'm writing so stay tuned for more!

## Thanks!

Thanks for reading my post! In case you have any questions, feel free to leave a comment on DEV or send me a message on [Twitter](https://twitter.com/beeman_nl)!

Happy coding!

Cheers, beeman 🐝

[^1]: Cross-posting is [considered bad](https://support.google.com/webmasters/answer/139066?hl=en) for your SEO score. To address this issue, DEV [conveniently supports](https://dev.to/page/faq#what-about-my-posts-google-ranking) the **canonical_url** property. Another reason to ❤️ DEV!