Hatchgrid CI/CD Workflow Guide
🧾 Hatchgrid CI/CD Workflow Guide
Section titled “🧾 Hatchgrid CI/CD Workflow Guide”This guide describes how the GitHub Actions workflows are configured for Hatchgrid and how to maintain or extend them.
📋 Workflow Overview
Section titled “📋 Workflow Overview”Main Workflows
Section titled “Main Workflows”- Monorepo CI (
monorepo-ci.yml
) - Main continuous integration pipeline - Backend CI (
backend-ci.yml
) - Backend-specific CI (Kotlin/Java) - Frontend CI (
frontend-ci.yml
) - Frontend-specific CI (Node.js/TypeScript) - Deploy (
deploy.yml
) - Deployment pipeline to different environments
Support Workflows
Section titled “Support Workflows”- Cleanup Cache (
cleanup-cache.yml
) - Automatic cache cleanup - Issue Labeler (
issue-labeler.yml
) - Automatic issue labeling - Semantic PR (
semantic-pull-request.yml
) - PR title validation - Test PNPM (
test-pnpm.yml
) - PNPM configuration testing
🔄 Monorepo CI Workflow
Section titled “🔄 Monorepo CI Workflow”File: .github/workflows/monorepo-ci.yml
Triggers
Section titled “Triggers”- Push to
main
(excludes markdown files and specific workflows) - Pull requests (excludes markdown files and specific workflows)
- Manual execution with environment selection
Main Jobs
Section titled “Main Jobs”1. labeler
Section titled “1. labeler”- Automatically labels PRs based on modified paths
- Uses
actions/labeler@v5
2. codeql-analysis
Section titled “2. codeql-analysis”- Security analysis with CodeQL
- Languages:
javascript
,kotlin
- Uploads results to GitHub Security
3. super-linter
Section titled “3. super-linter”- Code validation with multiple linters
- Configured with
VALIDATE_ALL_CODEBASE: true
4. dependency-review
Section titled “4. dependency-review”- Scans PRs for dependency vulnerabilities
- Automatically comments on PRs
5. owasp-dependency-check
Section titled “5. owasp-dependency-check”- OWASP security analysis
- Fails if vulnerabilities with CVSS ≥ 7 are found
- Generates HTML report as artifact
6. backend
and frontend
Section titled “6. backend and frontend”- Runs delegated backend and frontend workflows
- Runs in parallel to optimize time
7. integration
Section titled “7. integration”- Runs after backend and frontend
- Downloads artifacts from both
- Executes
./gradlew integrationTest
- Uploads integration reports
Concurrency
Section titled “Concurrency”concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true
🏗️ Backend CI Workflow
Section titled “🏗️ Backend CI Workflow”File: .github/workflows/backend-ci.yml
Triggers
Section titled “Triggers”- Changes in
server/**
,shared/**
, Gradle files - Push to
main
and pull requests
1. lint
- Detekt with Reviewdog
Section titled “1. lint - Detekt with Reviewdog”- Runs static analysis with Detekt
- Uses Reviewdog for PR comments
- Generates SARIF reports
2. build
- Build and Test
Section titled “2. build - Build and Test”- Compiles with Gradle (
./gradlew build -x test
) - Runs tests (
./gradlew test
) - Publishes test results
- Uploads coverage to Codecov (Kover)
- Generates artifacts (JARs and reports)
Environment Variables
Section titled “Environment Variables”NVD_API_KEY
- For vulnerability analysis
🎨 Frontend CI Workflow
Section titled “🎨 Frontend CI Workflow”File: .github/workflows/frontend-ci.yml
Triggers
Section titled “Triggers”- Changes in
client/**
, Node.js configuration files - Push to
main
and pull requests
1. lint
- Biome with Reviewdog
Section titled “1. lint - Biome with Reviewdog”- Linting with Biome
- Automatic PR comments via Reviewdog
- Configured to fail on errors
2. build
- Build
Section titled “2. build - Build”- Compiles frontend applications (
pnpm build
) - Uploads build artifacts
3. test
- Test
Section titled “3. test - Test”- Runs tests (
pnpm test
) - Uploads coverage to Codecov
🚀 Deploy Workflow
Section titled “🚀 Deploy Workflow”File: .github/workflows/deploy.yml
Triggers
Section titled “Triggers”- Manual with environment selection (development, staging, production)
- Push to
main
→ automatic deployment to development - Tags
v*
→ automatic deployment to production
1. determine-environment
Section titled “1. determine-environment”- Determines deployment environment based on trigger
2. build-backend
Section titled “2. build-backend”- Compiles backend with Gradle
- Builds and pushes Docker image
- Scans image with Trivy
- Uploads security results
3. build-frontend
Section titled “3. build-frontend”- Compiles frontend with pnpm
- Builds and pushes Docker image
- Scans image with Trivy
- Uploads security results
4. deploy
Section titled “4. deploy”- Configures kubectl
- Updates Kubernetes manifests
- Deploys to Kubernetes
- Waits for deployment confirmation
Concurrency
Section titled “Concurrency”concurrency: group: deploy-${{ github.ref_name }}-${{ inputs.environment || 'development' }} cancel-in-progress: false
🛠️ Support Workflows
Section titled “🛠️ Support Workflows”Cleanup Cache
Section titled “Cleanup Cache”- Runs when a PR is closed
- Automatically cleans branch caches
- Uses GitHub CLI for cache management
Issue Labeler
Section titled “Issue Labeler”- Automatically labels issues when opened or edited
- Configuration in
.github/issue-labeler-config.yml
Semantic Pull Request
Section titled “Semantic Pull Request”- Validates PR titles according to Conventional Commits
- Automatically comments if title is invalid
- Removes comments when corrected
Test PNPM
Section titled “Test PNPM”- Test workflow for PNPM configuration
- Manual execution only
- Verifies installation and configuration
📦 Caching Strategy
Section titled “📦 Caching Strategy”Gradle Cache
Section titled “Gradle Cache”path: | ~/.gradle/caches ~/.gradle/wrapperkey: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
PNPM Cache
Section titled “PNPM Cache”path: ~/.pnpm-storekey: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
🔧 Extensions and Maintenance
Section titled “🔧 Extensions and Maintenance”Add new language to CodeQL
Section titled “Add new language to CodeQL”matrix: language: [ 'javascript', 'kotlin', 'java' ]
Configure notifications
Section titled “Configure notifications”- Slack:
slackapi/slack-github-action
- Discord: custom webhook
- Teams:
skitionek/notify-microsoft-teams
Update action versions
Section titled “Update action versions”- Use specific versions with SHA hash
- Review regularly with Dependabot
- Test in development environment first
🔒 Security
Section titled “🔒 Security”Minimal Permissions
Section titled “Minimal Permissions”- Each workflow has specific minimal permissions
contents: read
by default- Additional permissions only when necessary
Security Scanning
Section titled “Security Scanning”- CodeQL for static analysis
- OWASP Dependency Check for dependencies
- Trivy for Docker images
- Dependency Review for PRs
Required Secrets
Section titled “Required Secrets”CODECOV_TOKEN
- For uploading coverageNVD_API_KEY
- For vulnerability analysisKUBECONFIG
- For Kubernetes deployments