Workflow Syntax Deep Dive
Events
on:
push:
branches: [main, 'release/*']
paths-ignore: ['**.md']
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: '0 9 * * 1' # Every Monday at 9am UTC
workflow_dispatch: # Manual trigger from GitHub UI
Contexts and expressions
steps:
- run: echo "Branch is ${{ github.ref_name }}"
- run: echo "Actor is ${{ github.actor }}"
- if: github.event_name == 'push'
run: echo "This is a push event"
Job dependencies
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: npm test
deploy:
needs: test # Only runs if test passes
runs-on: ubuntu-latest
steps:
- run: ./deploy.sh
Secrets
- name: Deploy
env:
API_KEY: ${{ secrets.MY_API_KEY }}
run: curl -H "Authorization: Bearer $API_KEY" https://api.example.com/deploy