DEV Community

Denz Mek
Denz Mek

Posted on

Automating Blog Posts to Dev.to with GitHub Actions

Hey Dev.to πŸ‘‹

Just wanted to share a quick setup I’m using to publish posts directly to Dev.to using GitHub Actions.

Basically, I write my blog in Markdown, commit it to GitHub, and the post goes live automatically. No manual copy-paste, no forgetting to publish. Super simple, but saves time and keeps everything version-controlled.

This post itself was published that way.

Why bother?

I got tired of switching between editors, formatting things twice, or forgetting what I published where. So I wrote a small Python script that pushes the post to Dev.to, and wrapped it in a GitHub Action. Now it’s just:

git push
Enter fullscreen mode Exit fullscreen mode

…and boom πŸ’₯ β€” post is live.

How it works

You just need:

A publish_to_devto.py script (uses the Dev.to API)

Your blog posts in a /posts folder

A GitHub Action that runs the script on push

Your Dev.to API key stored as a GitHub secret

That’s it.

Folder layout
Here’s what the repo looks like:

.
β”œβ”€β”€ posts/
β”‚   └── hello-devto.md
β”œβ”€β”€ publish_to_devto.py
β”œβ”€β”€ .github/workflows/publish.yml
β”œβ”€β”€ requirements.txt
Enter fullscreen mode Exit fullscreen mode

One-time setup

Add your Dev.to API key as a GitHub secret (e.g., DEVTO_API_KEY)

Write your blog in Markdown

Push to GitHub

That’s it β€” your post will show up on your Dev.to profile.

This is the first one I’ve published using the flow β€” just testing it out, and so far it works.

Will share the code and full setup in the next post if anyone’s interested.

Cheers πŸ‘‹

Top comments (0)