mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
92 words
1 minute
GitHub Actions: Automate Your Workflow

What Are GitHub Actions?#

GitHub Actions is a CI/CD platform built directly into GitHub. It lets you automate builds, tests, and deployments triggered by events in your repository.

Your First Workflow#

Create .github/workflows/ci.yml:

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run build

Matrix Builds#

Test across multiple versions simultaneously:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci && npm test

Caching Dependencies#

Speed up workflows by caching dependencies:

- uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: pnpm-

Deploy to Vercel on Push#

name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}
vercel-args: '--prod'

Useful Patterns#

Run only when specific files change#

on:
push:
paths:
- 'src/**'
- 'package.json'

Manual triggers#

on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
default: 'staging'
type: choice
options:
- staging
- production

Reusable workflows#

.github/workflows/reusable-test.yml
on:
workflow_call:
inputs:
node-version:
required: true
type: string
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- run: npm ci && npm test

GitHub Actions eliminates the need for external CI services. With the generous free tier (2,000 minutes/month for private repos), there’s no reason not to automate your workflow.

Share

If this article helped you, please share it with others!

GitHub Actions: Automate Your Workflow
https://blog.levifree.com/posts/github-actions-automate-workflow/
Author
LeviFREE
Published at
2026-06-22
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents