A simple guide to help you set up a GitHub Action for Continuous Integration (CI) in your project.
GitHub Actions lets you automate, customize, and execute your software development workflows right in your GitHub repository. It's commonly used for CI/CD pipelines.
your-repo/
β
βββ .github/
β βββ workflows/
β βββ ci.yml <-- Your GitHub Actions workflow file
β
βββ src/
β βββ your-code.js
βββ tests/
β βββ your-tests.test.js
βββ package.json
βββ README.md- In your project root, create folders:
mkdir -p .github/workflows
- touch .github/workflows/ci.yml add the following inside your ci.yml file
name: π¨ Run Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π’ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: π¦ Install dependencies
run: npm ci
- name: β
Run tests
run: npm test