Created by Gagan Sir
Module 05: GitHub Actions Architecture, Syntax, Triggers & Matrix
Git Basics + GitHub Workflows + Actions CI/CD + Security + Releases + CLI + REST/GraphQL APIs + 150+ Q&A
29
GitHub Actions Architecture
🇬🇧 English Definition
GitHub Actions is an automated workflow engine integrated into GitHub. Workflows are declared in YAML under `.github/workflows/`. Workflows respond to events, execute jobs on runners, and run sequential steps.
🇮🇳 Hinglish Definition
GitHub Actions GitHub ka builtin automation engine hai. Event trigger hone par YAML workflow runner machine par jobs aur steps automatically run karta hai.
🔄 Actions Architecture Flowchart
Event
Push / PR / Cron
➔
Workflow YAML
.github/workflows/
➔
Jobs
Runners
➔
Steps
Actions / Commands
➔
Artifact / Deploy
Output
30
Workflow YAML Syntax & Example
name: CI on: push: branches: [main] pull_request: permissions: contents: read jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - run: echo "Run tests here"
31 & 32
Triggers, Jobs, Steps & Runners
on: push: branches: [main] pull_request: branches: [main] workflow_dispatch: schedule: - cron: "0 2 * * 1" release: types: [published]
33
Contexts and Expressions
// Useful Context Expressions: ${{ github.ref }} ${{ github.sha }} ${{ github.actor }} ${{ github.repository }} ${{ github.event_name }} ${{ runner.os }} ${{ matrix.node }} ${{ secrets.DEPLOY_KEY }} ${{ vars.APP_ENV }} ${{ needs.build.outputs.version }}
34
Conditions, Matrix Builds & Step Outputs
jobs: test: strategy: fail-fast: false matrix: node: ["20", "22"] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 with: node-version: ${{ matrix.node }} - run: npm ci - run: npm test
35
Artifacts and Dependency Caching
// Upload Artifact - name: Upload Build Artifact uses: actions/upload-artifact@v4 with: name: build-dist path: dist/ // Download Artifact - name: Download Build Artifact uses: actions/download-artifact@v4 with: name: build-dist path: dist/