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.
More on Write-a-pipeline tasks
Write a GitHub Actions workflow that runs tests on every PR and push to main.BeginnerWrite a workflow that builds a Docker image and pushes it to ECR using OIDC (no access keys).IntermediateWrite a matrix job that tests on Python 3.10, 3.11 and 3.12 on Linux and Windows.BeginnerWrite a declarative Jenkinsfile with build, test, Docker push and a manual approval before prod.AdvancedWrite a GitHub Actions deploy job that requires approval for production using environments.BeginnerWrite a reusable workflow and call it from another repo.Intermediate