GitHub Pipelines
How to use GitHub Actions for automated workflows
GitHub Actions (Pipelines) allow you to automate your software development workflows. You can build, test, and deploy your code right from GitHub.
Overview
In NStrim, pipelines are primarily used for:
- Automated Testing — Run unit and integration tests on every push
- Code Quality — Run linters and static analysis tools
- Building — Compile assets or build Docker images
- Deployment — Trigger updates to session infrastructure
How to Add a Pipeline
To add a pipeline to your dev-ops template or repository:
- Create a
.github/workflowsdirectory in the root of your project - Create a
.ymlfile inside that directory (e.g.,main.yml) - Define your workflow using YAML syntax
Example: Basic Laravel Test Workflow
This example runs Pest tests on every push to the main branch:
name: Run Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, dom, curl, libxml, mysql
coverage: none
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Execute tests (Unit and Feature tests) via Pest
env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: testing
DB_USERNAME: root
DB_PASSWORD: password
run: php artisan test
Example: Node.js / React Workflow
This workflow installs dependencies and runs builds for a frontend project:
name: Node.js CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build --if-present
- name: Run tests
run: npm test
Pro Tip: You can use GitHub Secrets to store sensitive information like API keys or deployment credentials. Access them in your workflow using
${{ secrets.SECRET_NAME }}.
Manual Adjustments
When adding pipelines manually to existing repositories:
- Ensure the branch name in the workflow matches your repository's default branch (usually
mainormaster) - Update environment variables to match the NStrim session infrastructure
- Check that Docker images used in the workflow are compatible with your project requirements