Skip to content

feat: Automate nightly news article generation with MCP integration#345

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/automate-nightly-news-generation
Closed

feat: Automate nightly news article generation with MCP integration#345
Copilot wants to merge 2 commits intomainfrom
copilot/automate-nightly-news-generation

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Manual article creation for 14 languages consumed 2–4 hours daily and was error-prone. This adds a fully automated nightly pipeline: fetch → threshold → generate → validate → PR.

New files

  • scripts/generate-daily-news.js — Orchestrator that queries riksdag-regering-mcp for documents published since yesterday, groups by type (bet/prop/mot), skips types below the minimum document threshold (default ≥5), and delegates HTML generation to the existing generate-news-enhanced.js engine. Week Ahead is always generated.

    # Typical nightly invocation (all 14 languages, threshold=5)
    node scripts/generate-daily-news.js --languages=all --threshold=5
    
    # Override date window, restrict types, dry-run
    node scripts/generate-daily-news.js --date=2026-02-18 --types=committee-reports --dry-run
  • .github/workflows/nightly-news-generation.yml — Scheduled at 02:00 CET (0 1 * * *). All actions SHA-pinned. Supports workflow_dispatch with inputs for date, threshold, languages, types, and dry_run. Runs HTMLHint on generated files, updates indexes/sitemap, and opens a labeled PR via peter-evans/create-pull-request@v8.1.0.

  • ARTICLE_ENHANCEMENT_GUIDE.md — Definitive 892-line reference consolidating patterns from Issues Enhance Committee Reports Articles with Full Data Analysis and Commentary (2026-02-10 to 2026-02-14) #306–334 (176 articles enhanced). Covers: all 32 MCP tool call examples, 150–400 word quality standards, The Economist style guidelines, 14-language translation order and RTL requirements, Schema.org synchronization requirements, index/sitemap update process, and 8 documented pitfalls (cold-start handling, professional translation safety guards, 1 MB patch-size limit, etc.).

package.json

Added generate-daily-news npm script entry pointing to the new orchestrator.

Original prompt

This section details on the original issue you should resolve

<issue_title>Automate Nightly News Article Generation with MCP Integration</issue_title>
<issue_description># 📋 Issue Type
Automation / Process Improvement

🎯 Objective

Create automated nightly news generation script that fetches latest Riksdag documents via MCP and generates enhanced articles with proper analysis automatically, eliminating manual article creation.

📊 Current State

Manual Process: Articles are created manually or semi-manually:

  • Identify new documents (propositions, motions, committee reports)
  • Fetch data via MCP
  • Generate analysis
  • Create 14 language versions
  • Update indexes and sitemap

Problem: Time-consuming, error-prone, inconsistent quality

🚀 Desired State

Automated Workflow:

// Runs nightly at 02:00 CET via GitHub Actions
1. Fetch new documents from riksdag-regering MCP (last 24 hours)
2. Group by type (committee reports, propositions, motions)
3. Generate articles if threshold met (≥5 documents per type)
4. Apply content enhancement (150-400 word analysis)
5. Generate content-based titles
6. Create all 14 language versions
7. Update news indexes
8. Update sitemap.xml
9. Create PR with changes
10. Notify maintainers

🔧 Implementation Approach

Step 1: Create Generation Script

File: scripts/generate-daily-news.js

// Workflow:
// 1. Query MCP for new documents (last 24 hours)
riksdagRegering.searchDokument({
  rm: "2025/26",
  dateFrom: "YYYY-MM-DD" // yesterday
})

// 2. Group by document type
const committeeReports = docs.filter(d => d.doktyp === 'bet')
const propositions = docs.filter(d => d.doktyp === 'prop')
const motions = docs.filter(d => d.doktyp === 'mot')

// 3. Generate article if threshold met (≥5 docs)
if (committeeReports.length >= 5) {
  generateArticle({
    type: 'committee-reports',
    date: today,
    documents: committeeReports
  })
}

// 4. Apply enhancement template
// 5. Translate to 14 languages
// 6. Update indexes and sitemap
// 7. Commit and push

Step 2: GitHub Actions Workflow

File: .github/workflows/nightly-news-generation.yml

name: Nightly News Generation

on:
  schedule:
    - cron: '0 2 * * *'  # 02:00 CET daily
  workflow_dispatch:  # Allow manual trigger

jobs:
  generate-news:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '24'
      
      - name: Install dependencies
        run: npm install
      
      - name: Generate daily news
        run: node scripts/generate-daily-news.js
        env:
          MCP_AUTH_TOKEN: ${{ secrets.MCP_AUTH_TOKEN }}
      
      - name: Create PR
        uses: peter-evans/create-pull-request@v6
        with:
          title: "📰 Daily news: ${{ env.DATE }}"
          body: "Automated daily news generation"
          branch: "auto/daily-news-${{ env.DATE }}"

Step 3: Quality Controls

  • Minimum document threshold (≥5 per type)
  • MCP data validation
  • HTML validation before commit
  • Link checking
  • Fallback to manual if errors

✅ Acceptance Criteria

  • Script scripts/generate-daily-news.js created
  • GitHub Actions workflow .github/workflows/nightly-news-generation.yml
  • MCP integration working (fetch, analyze, enhance)
  • 14-language generation automated
  • Index/sitemap updates automated
  • PR creation automated
  • Error handling with notifications
  • Manual trigger option available
  • Documentation in ARTICLE_ENHANCEMENT_GUIDE.md

📚 References

🤖 Recommended Agent

devops-engineer or data-pipeline-specialist

📝 Notes

High value: Eliminates 2-4 hours of manual work daily. Ensures consistent quality and timely publication. Reduces human error.

Dependencies: Should implement after Issue #338 (documentation) to follow proven patterns.

Timeline: 3-5 days</issue_description>

<agent_instructions>Create comprehensive ARTICLE_ENHANCEMENT_GUIDE.md documenting the complete workflow from Issues #306-334. Include: step-by-step process, all 32 MCP tool examples, content quality standards (150-400 words), translation workflow for 14 languages, validation steps, best practices, and common pitfalls. Reference successful PRs #307, #312, #313, #314, #326, #333, #334. Make it a definitive guide for future article generation.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Automate nightly news article generation with MCP integration feat: Automate nightly news article generation with MCP integration Feb 19, 2026
Copilot AI requested a review from pethers February 19, 2026 17:29
@pethers pethers closed this Feb 19, 2026
@pethers pethers deleted the copilot/automate-nightly-news-generation branch February 19, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate Nightly News Article Generation with MCP Integration

2 participants

Comments