Tech Handbook Null Yard

CI/CD and GitHub Actions

CI automates validation of a change, while CD automates delivery. A good pipeline should be repeatable, easy to diagnose and built from the same commands that can be run locally.

Related topics: Git in Team Workflows, GitHub, Software Testing, Docker and Logging, Monitoring and Troubleshooting.

1. CI and CD

CI:

commit → test → build

CD:

build → deploy

The goal is to automate repeatable steps.

2. GitHub Actions

A workflow lives in:

.github/workflows/ci.yml

3. Minimal workflow

name: CI

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v7

      - name: Test
        run: echo "Run tests here"

4. Go

- uses: actions/setup-go@v5
  with:
    go-version: '1.25'

- run: go test ./...
- run: go build ./...

5. Node

- uses: actions/setup-node@v4
  with:
    node-version: 22

- run: npm ci
- run: npm test
- run: npm run build

6. Triggers

Only main:

on:
  push:
    branches: [main]

Manual trigger:

on:
  workflow_dispatch:

7. Jobs

jobs:
  test:
    ...
  build:
    needs: test
    ...
  deploy:
    needs: build
    ...

8. Matrix

strategy:
  matrix:
    node: [20, 22]

This lets you test against several versions.

9. Secrets

GitHub:

Settings → Secrets and variables → Actions

Workflow:

env:
  API_TOKEN: ${{ secrets.API_TOKEN }}

Never print secrets to logs.

10. Artifacts

- uses: actions/upload-artifact@v4
  with:
    name: build
    path: dist/

11. Docker build

- run: docker build -t myapp:${{ github.sha }} .

12. Container Registry

GitHub Container Registry:

ghcr.io/OWNER/IMAGE

Typical flow:

commit
 ↓
test
 ↓
docker build
 ↓
push image
 ↓
deploy

13. Deployment over SSH

GitHub Actions
  ↓ SSH
VPS
  ↓
docker compose pull
docker compose up -d

Store deployment keys as secrets.

14. Environments

You may define development, staging and production environments with separate secrets and approvals.

15. Pull Request checks

Before merge, require tests, build and linting where appropriate.

16. Cache

Node:

with:
  cache: npm

Go workflows can also cache modules and build data.

17. Workflow permissions

Grant only what is needed.

permissions:
  contents: read

18. Release workflow

For tags:

on:
  push:
    tags:
      - 'v*'

You can build binaries, create a release and publish a Docker image.

19. CI for a small project

A good starting point:

push/PR
  ↓
format/lint
  ↓
tests
  ↓
build

Do not begin with an unnecessarily complex pipeline.

20. Common problems

  • local and runner environments differ,
  • missing secrets,
  • incorrect permissions,
  • inconsistent Node/Go versions,
  • deployment runs despite failed tests,
  • unversioned latest-only images.

21. What you should know

You should be able to write a basic workflow, run tests and builds, use secrets, build a container, connect CI with deployment and understand job dependencies.

Official references

  • GitHub Actions documentation: https://docs.github.com/actions
  • Workflow syntax: https://docs.github.com/actions/writing-workflows/workflow-syntax-for-github-actions