Interview Prep/Real-World Interview/Write-a-pipeline tasks

Write a scheduled workflow that runs nightly and can also be triggered manually with an input.

BeginnerHands-onWrite-a-pipeline tasks
Answer
on:
  schedule:
    - cron: "30 20 * * *"     # 20:30 UTC = 02:00 IST
  workflow_dispatch:
    inputs:
      env:
        type: choice
        options: [staging, prod]
        default: staging
jobs:
  drift:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Checking drift in ${{ inputs.env || 'staging' }}"

Key trick → Cron in Actions is always UTC and can be delayed under load. inputs.env is empty on scheduled runs, so use || to give a default.

All Real-World Interview questions Roadmap: Interview readiness

More on Write-a-pipeline tasks