Skip to the content.

GitHub CI/CD Tips and Tricks

While Jenkins is the primary CI/CD tool for SMI projects, we often interact with GitHub Actions for public repositories or specific automation tasks.

Docker Images in CI

Docker is the cornerstone of our CI strategy. It ensures that the build environment matches the developer environment.

Using Official and Custom Images

Building with Docker

In GitHub Actions, you can run steps inside a container:

jobs:
    build:
        runs-on: ubuntu-latest
        container:
            image: cimg/android:2024.01
        steps:
            -   uses: actions/checkout@v4
            -   run: npm ci
            -   run: npm test

Docker-in-Docker (DinD) vs. Socket Binding

Example (DinD service):

jobs:
  build:
    runs-on: ubuntu-latest
    services:
      docker:
        image: docker:dind
        options: --privileged
    steps:
      - uses: actions/checkout@v4
      - run: docker info

GitHub Actions Tips

Triggers and Filtering

Avoid running CI on every minor change. Use path filtering to save resources:

on:
    push:
        branches: [ master, develop ]
        paths:
            - 'src/**'
            - 'package.json'
            - '.github/workflows/**'

Secrets Management

Environment Variables

Standardize environment variables across Jenkins and GitHub:

Caching for Speed

Always use caching for node_modules, Gradle, and Maven dependencies:

-   name: Cache npm modules
    uses: actions/cache@v4
    with:
        path: ~/.npm
        key: $-node-$
        restore-keys: |
            $-node-

Workflows

Multi-workspace Projects (npm)

When working with npm workspaces, use the --workspaces flag in your CI scripts to ensure all modules are tested:

-   run: npm ci
-   run: npm test --workspaces

Android/iOS Builds

See also