This repository demonstrates how to use bit.dev GitHub Actions to automate Bit workflows for component development and management.
This project showcases three essential GitHub Actions workflows that integrate Bit with your CI/CD pipeline:
- Verify: Validates workspace status and builds components
- Pull Request: Exports components to lanes and generates version labels
- Merge: Handles component versioning and exports to main
ci-scripts-demo/
├── .github/workflows/
│ ├── verify.yml # Workspace verification on main branch
│ ├── pull-request.yml # PR validation and lane management
│ └── merge.yml # Component versioning and export
├── bit-components/ # Bit components directory
│ └── design/
│ ├── envs/
│ ├── patterns/
│ └── ui/
└── workspace.jsonc # Bit workspace configuration
Trigger: Push to main
branch
Purpose: Ensures the workspace is in a healthy state by running status checks and building all components.
Actions:
- Initializes Bit workspace
- Runs
bit status
to check for issues - Builds all components to ensure they compile correctly
name: Bit verify
on:
push:
branches: [main]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bit-tasks/init@v3
- uses: bit-tasks/verify@v2
Trigger: Pull request opened or synchronized
Purpose: Validates changes, creates a Bit lane with component modifications, and generates version labels for semantic versioning.
Actions:
- Creates a Bit lane and adds component changes for verification
- Builds components to ensure they compile correctly
- Automatically generates GitHub labels for version bumps (major, minor, patch)
- Applies color-coded labels for easy identification
- Supports both component-specific and global version labels
Version Label Types:
- Component-specific:
component-name@major
,component-name@minor
,component-name@patch
- Global overrides:
[major]
,[minor]
,[patch]
,pre-release:<flag>
Label Colors:
- 🔴 Major:
#f0a09f
- 🟡 Minor:
#f0e8bd
- 🟢 Patch:
#c2e0c6
name: Bit PR Check
on:
pull_request:
types: [opened, synchronize]
jobs:
verify:
steps:
- uses: bit-tasks/pull-request@v3
with:
build: true
version-labels: true
version-labels-color-major: "f0a09f"
version-labels-color-minor: "f0e8bd"
version-labels-color-patch: "c2e0c6"
clear-labels: true
Trigger: Pull request merged to main
Purpose: Executes bit ci merge
to tag and export components with intelligent version detection.
Actions:
- Analyzes the last merged pull request for version keywords
- Tags components with appropriate semantic versions
- Builds components before tagging (when enabled)
- Exports components to the remote scope on bit.cloud
Version Detection Priority:
- Pull Request Labels: Version labels like
[major]
,[minor]
,[patch]
- Pull Request Title: Version keywords in square brackets (e.g., "Fix bug [patch]")
- Input Parameters: Fallback to workflow configuration
Supported Version Keywords:
[major]
- Breaking changes[minor]
- New features[patch]
- Bug fixes (default)[pre-release:<flag>]
- Pre-release versions (e.g.,[pre-release:beta]
)
name: Bit Merge
on:
pull_request:
types: [closed]
branches: [main]
jobs:
main-merge:
if: github.event.pull_request.merged == true
steps:
- uses: bit-tasks/tag-export@v3
with:
build: true
increment: "patch" # Fallback version
- Bit Account: Create an account at bit.cloud
- Bit Workspace: Initialize a Bit workspace in your repository
- GitHub Repository: Host your code on GitHub
- Bit Version: Ensure you're using Bit version ^1.11.42 or higher
bit-tasks/verify@v2
requires Bit ^1.11.42bit-tasks/pull-request@v3
requires Bit ^1.11.42bit-tasks/tag-export@v3
requires Bit ^1.12.45
Add these secrets to your GitHub repository settings:
Secret | Description | Required For |
---|---|---|
BIT_CONFIG_ACCESS_TOKEN |
Bit.dev access token for authentication | All workflows |
GITHUB_TOKEN |
GitHub token (automatically provided) | PR and Merge workflows |
GIT_USER_NAME |
Git username for commits | Merge workflow |
GIT_USER_EMAIL |
Git email for commits | Merge workflow |
Ensure your GitHub workflows have the necessary permissions:
permissions:
contents: write # For merge workflow
pull-requests: write # For PR and merge workflows
- Go to bit.cloud
- Navigate to your profile settings
- Generate a new access token
- Add it as
BIT_CONFIG_ACCESS_TOKEN
in your GitHub repository secrets
Note: The secret must be named BIT_CONFIG_ACCESS_TOKEN
(not BIT_ACCESS_TOKEN
) for the actions to work properly.
The workspace.jsonc
file configures your Bit workspace:
{
"teambit.workspace/workspace": {
"name": "ci-scripts-demo-2",
"defaultDirectory": "bit-components/{scope}/{name}",
"defaultScope": "automations.design"
}
}
- Create/Modify Components: Work on your Bit components locally
- Create Pull Request: Push changes and open a PR
- The PR workflow will validate your changes
- Version labels will be automatically generated
- Review and Merge: After review, merge the PR
- The merge workflow will apply versioning and export to bit.cloud
You can control versioning in multiple ways:
Component-Specific Labels (applied to individual components):
ui/button@major
- Force major version bump for ui/button componentui/button@minor
- Force minor version bump for ui/button componentui/button@patch
- Force patch version bump for ui/button component
Global Version Labels (applied to all modified components):
[major]
- Breaking changes across all components[minor]
- New features across all components[patch]
- Bug fixes across all components[pre-release:beta]
- Pre-release version with custom identifier
PR Title Keywords (alternative to labels):
- "Update component with breaking changes [major]"
- "Add new feature [minor]"
- "Fix critical bug [patch]"
- "Release candidate [pre-release:rc]"
Components are organized under bit-components/
following the pattern:
bit-components/{scope}/{component-name}/
Verify Workflow Options:
ws-dir
: Specify workspace directory (default: current directory)strict
: Fail on warnings as well as errors
Pull Request Workflow Options:
build
: Build components during verificationstrict
: Enable strict mode for enhanced validationclear-labels
: Automatically remove old Bit labels- Custom label colors for better visual organization
Merge Workflow Options:
persist
: Add--persist
flag for soft tagged componentsbuild
: Build components before taggingstrict
: Enable strict mode for taggingincrement
: Fallback version increment (major, minor, patch)prerelease-id
: Custom pre-release identifier (alpha, beta, rc)
This repository serves as a demonstration of Bit GitHub Actions integration. Feel free to explore the workflows and adapt them to your own projects.