How to Automate Blog Posts with GitHub Actions
I auto-generate one blog post per week about Japan travel. Here's the exact setup.
The System
GitHub Actions → API → Generate Article → Post to Dev.to
Step 1: Article Pool
I have 19 pre-written articles about Japan in a JSON pool:
{
"slug": "curiosidades-japon",
"title": "15 Curiosidades de Japón",
"category": "Curiosidades",
"content": "..."
}
Step 2: GitHub Action
name: Auto Blog Post
on:
schedule:
- cron: '0 10 * * 1' # Every Monday at 10am UTC
workflow_dispatch:
jobs:
post:
runs-on: ubuntu-latest
steps:
- name: Generate and Post
run: |
# Get next article from pool
ARTICLE=$(curl -s -X POST $API_URL/v1/blog/generate)
# Extract content
TITLE=$(echo $ARTICLE | jq -r '.post.title')
CONTENT=$(echo $ARTICLE | jq -r '.post.content')
TAGS=$(echo $ARTICLE | jq -r '.post.tags | join(",")')
# Post to Dev.to
curl -X POST https://dev.to/api/articles \
-H "api-key: ${{ secrets.DEVTO_API_KEY }}" \
-H "Content-Type: application/json" \
-d "{
"article": {
"title": "$TITLE",
"body_markdown": "$CONTENT",
"tags": ["webdev", "javascript"],
"published": true
}
}"
Step 3: Secrets
Add your Dev.to API key as a GitHub secret:
- Go to repo Settings → Secrets → Actions
- Add
DEVTO_API_KEY
Results
- 1 article/week automatically
- 0 manual work after setup
- Cross-posted to website + Dev.to
- SEO optimized with metadata
Cost
- GitHub Actions: Free (2000 minutes/month)
- Dev.to API: Free
- Total: $0/month
Source code: github.com/storbaz/japan-travel-api
Top comments (0)