This guide demonstrates setting up custom scripts with GitHub Actions to automate tasks on a schedule.

Embracing the wave of content generation through LLMs since 2023, SakeSaySo leverages Anthropic AI in its news aggregation process. We use GitHub Actions, combined with Go-based tools and scripts that we prefer over Python, to automate such tasks. The configuration below is an example setup, including a cron schedule, showcasing how you can replicate this for your needs.

name: Go Scheduled Newswriter

on:
  push:
    branches: [ master ]
  schedule:
    - cron: '0 21 * * *'  # Runs at 21:00 UTC (6 AM JST)

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Current Repository
      uses: actions/checkout@v2

    - name: Checkout sakesayso/news Repository
      uses: actions/checkout@v2
      with:
        repository: 'sakesayso/news'
        token: ${{ secrets.SAKESAYSO_WRITER_PAT }}
        path: 'news'

    - name: Set up Go
      uses: actions/setup-go@v2
      with:
        go-version: '1.21'

    - name: Run Newswriter A
      env:
        ANTHROPIC_TOKEN: ${{ secrets.ANTHROPIC_TOKEN }}
      run: go run cmd/newswriter/main.go

    - name: Commit and Push Changes
      run: |
        cd news
        git config --global user.name 'sakebot'
        git config --global user.email '[email protected]'
        git add .
        git commit -m "Update from newswriter" || true
        git push

This configuration details the steps from checking out repositories to executing the Go script and pushing updates.