Archive · DevOps

Continuous Integration with GitHub Actions

A first pipeline that tests every push and every pull request.

1 min read

  • GitHub Actions
  • actions/checkout v3
  • Node.js 16

Continuous integration runs build and tests automatically on each change. With GitHub Actions the pipeline lives in the repository at .github/workflows/ci.yml.

name: ci
on:
  pull_request:
  push:
    branches: [main]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: npm
      - run: npm ci
      - run: npm test
  • cache: npm reuses downloaded packages and speeds up runs.
  • Store credentials under Settings, Secrets and read them as ${{ secrets.NAME }}.
  • Make the check required in branch protection so a failing build blocks the merge.

For deployments to AWS, prefer GitHub’s OIDC federation with an IAM role over long-lived access keys. Pin third-party actions to a version, and keep jobs fast: a pipeline people wait for is a pipeline they work around.