Skip to content

How to Set Up Scheduled Workflows in GitHub Actions in 5 Minutes

Target Audience

  • Developers who want to automate recurring tasks with GitHub Actions

Key Points

  1. Configure a GitHub Actions schedule trigger
  2. Understand basic cron syntax
  3. Run Claude Code on a schedule

How Scheduled Execution Works

GitHub Actions schedule events automatically run workflows at specified times. Internally they use cron expressions, but everything runs on GitHub, so no server setup is required.

Implementation Steps

Step 1: Create a Workflow File

Create .github/workflows/scheduled-task.yml:

name: Scheduled Task
on:
  schedule:
    - cron: '0 9 * * *'  # Daily at 9:00 AM (UTC)
  workflow_dispatch:  # Enable manual triggering

Step 2: Add Claude Code Execution Job

jobs:
  run-claude:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Claude Code
        env:
          CLAUDE_API_KEY: ${{ secrets.CLAUDE_API_KEY }}
        run: |
          # Execute automation task with Claude Code
          npx claude-code --task "Generate daily report"

Step 3: Push to GitHub to Activate

git add .github/workflows/scheduled-task.yml
git commit -m "Add scheduled workflow"
git push origin main

Common Cron Expression Patterns

ScheduleCron ExpressionJapan Time (JST)
Daily 9 AM0 0 * * *9:00
Weekdays 9 AM0 0 * * 1-59:00 (Mon-Fri)
Monday 9 AM0 0 * * 1Monday 9:00
1st of month 9 AM0 0 1 * *1st 9:00
Every 6 hours0 */6 * * *0, 6, 12, 18

※GitHub Actions uses UTC. Japan time is UTC+9

Troubleshooting

SymptomCauseSolution
Doesn't runIncorrect cron syntaxValidate with crontab.guru
Time offsetTimezoneCalculate in UTC (JST-9 hours)
Stops after 60 daysInactivityCommit to repository regularly
Advanced Configuration (Click to Expand) ### Multiple Schedules
on:
  schedule:
    - cron: '0 0 * * *'  # Daily
    - cron: '0 12 * * 5'  # Friday noon
### Environment-Specific Execution
jobs:
  scheduled-task:
    strategy:
      matrix:
        environment: [dev, staging, prod]
    runs-on: ubuntu-latest
    steps:
      - name: Run for ${{ matrix.environment }}
        run: echo "Running for ${{ matrix.environment }}"
### Add Error Notifications
- name: Error Notification
  if: failure()
  uses: actions/github-script@v7
  with:
    script: |
      github.rest.issues.create({
        owner: context.repo.owner,
        repo: context.repo.repo,
        title: 'Scheduled task failed',
        body: 'Check the workflow run for details'
      })

Next Steps


This article extracts and organizes GitHub Actions-specific content from multiple legacy cron-related articles.