Example Workflow
Below is a sample workflow YAML stored under.github/workflows/ in your repository:
Save each workflow file in the
.github/workflows/ directory. You can have multiple workflow files, each triggered by different events (e.g., pull_request, release, or a schedule).1. Workflows
A workflow is a configurable automated process defined by a YAML file. It listens for one or more events in your repository and runs one or more jobs. Key elements in the example above:name: My Awesome App
A custom label visible in the Actions tab.on: push
Defines the event(s) that trigger the workflow. You can specify multiple events and filters.
pull_requestschedule(cron jobs)workflow_dispatch(manual run)
2. Jobs
A job is a collection of steps executed on the same runner. By default, jobs run in parallel, but you can coordinate them using dependencies.- Job identifier (
unit-testing): used to set dependencies. runs-on: selects the runner environment (ubuntu-latest,windows-latest, etc.).
3. Steps
Within each job, steps define individual tasks. They execute sequentially on the same runner.- Use
usesto invoke an action. - Use
runto execute shell commands.
- Checkout Repository: Fetches your code.
- Setup Node.js: Installs Node.js and npm.
- Install Dependencies: Runs
npm install. - Execute Unit Tests: Runs your test suite.
4. Actions
An action is a reusable, shareable unit of automation. Use community or official actions from the GitHub Marketplace. You can also author custom actions.| Resource Type | Description | Example |
|---|---|---|
| Build & Push Docker Images | Constructs and publishes Docker images to a registry | docker/build-push-action@v3 |
| Create AKS Clusters | Provisions Azure Kubernetes Service clusters | Azure/aks-set-context@v1 |
| Consume Vault Secrets | Fetches secrets from Vault and exposes them as environment vars | hashicorp/vault-action@v2 |

Getting Started
- Create
.github/workflows/ci.ymlin your repo. - Define your
ontriggers. - Add jobs and steps to build, test, and deploy.