A GitHub Action that scans Turborepo monorepo repositories and extracts project
information for packages that contain a build property in their
package.json. This action is useful for CI/CD pipelines that need to identify
and process buildable projects within a monorepo structure.
- π Automatic Discovery: Scans your Turborepo workspace to find all packages
- π¦ Build-Ready Projects: Only includes projects with a
buildproperty in package.json - π·οΈ Version Extraction: Extracts name, version, and identifier from each project
- π― Build Grouping: Groups projects by build type for organized processing
- π Detailed Logging: Provides comprehensive logging of discovered projects
| Output | Description |
|---|---|
projects |
JSON string containing projects grouped by build type with their version information |
The projects output is a JSON object where:
- Keys: Build types (from the
buildproperty in package.json) - Values: Arrays of project information objects
Each project object contains:
path: File system path to the projectname: Package name from package.jsonversion: Package version from package.jsonidentifier: Normalized identifier derived from package namebuild: Build type(s) associated with the project
{
"docker": [
{
"path": "./apps/web-app",
"name": "@myorg/web-app",
"version": "1.2.3",
"identifier": "myorg-web-app",
"build": "docker"
}
],
"npm": [
{
"path": "./packages/shared-lib",
"name": "@myorg/shared-lib",
"version": "2.1.0",
"identifier": "myorg-shared-lib",
"build": "npm"
}
]
}Add this action to your workflow to scan your Turborepo monorepo:
name: Build Projects
on: [push, pull_request]
jobs:
scan-projects:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.scan.outputs.projects }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Scan Turborepo Projects
id: scan
uses: relab-services/turborepo-projects-version@v1
- name: Display Projects
run: echo '${{ steps.scan.outputs.projects }}'Use the output to create dynamic build matrices:
name: Build and Deploy
on: [push]
jobs:
scan:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.scan.outputs.projects }}
steps:
- uses: actions/checkout@v4
- id: scan
uses: relab-services/turborepo-projects-version@v1
build-docker:
needs: scan
if: contains(fromJSON(needs.scan.outputs.projects), 'docker')
strategy:
matrix:
project: ${{ fromJSON(needs.scan.outputs.projects).docker }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
run: |
echo "Building ${{ matrix.project.name }}@${{ matrix.project.version }}"
echo "Path: ${{ matrix.project.path }}"
# docker build -t ${{ matrix.project.identifier }}:\
# ${{ matrix.project.version }} ${{ matrix.project.path }}
build-npm:
needs: scan
if: contains(fromJSON(needs.scan.outputs.projects), 'npm')
strategy:
matrix:
project: ${{ fromJSON(needs.scan.outputs.projects).npm }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build NPM Package
run: |
echo "Building ${{ matrix.project.name }}@${{ matrix.project.version }}"
cd ${{ matrix.project.path }}
npm ci
npm run buildFor a project to be included in the scan results, it must have a build
property in its package.json. This property can be:
{
"name": "@myorg/web-app",
"version": "1.0.0",
"build": "docker"
}{
"name": "@myorg/shared-lib",
"version": "2.1.0",
"build": ["npm", "docker"]
}The action supports any build type you define. Common examples include:
docker- For containerized applicationsnpm- For npm packagesstatic- For static sitesserverless- For serverless functionsmobile- For mobile applications
my-monorepo/
βββ turbo.json
βββ package.json (with turbo dependency)
βββ apps/
β βββ web-app/
β β βββ package.json (build: "docker")
β βββ mobile-app/
β βββ package.json (build: "mobile")
βββ packages/
βββ ui-components/
β βββ package.json (build: "npm")
βββ shared-utils/
βββ package.json (build: ["npm", "docker"])
- Turborepo: Your repository must have Turborepo installed and configured
- Node.js: The action runs on Node.js 24.x
- Package.json: Projects must have a
buildproperty to be included in results
- Detection: Scans the root
package.jsonto find the Turborepo version - Discovery: Uses
turbo ls --output=jsonto discover all packages in the workspace - Analysis: Reads each package's
package.jsonto extract project information - Filtering: Only includes projects that have a
buildproperty - Grouping: Groups projects by their build type(s)
- Output: Returns structured JSON with all discovered projects
- Ensure
turbois listed in your rootpackage.jsondependencies or devDependencies - Verify your Turborepo configuration is valid
- Check that your packages have a
buildproperty in theirpackage.json - Verify that Turborepo can discover your packages with
turbo ls
- Ensure the project's
package.jsonexists and is valid JSON - Confirm the
buildproperty is present and not empty
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run
npm run allto format, lint, test, and build - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.