GitHub Actions Integration
Learn how to integrate Ocuroot with GitHub Actions
Ocuroot can integrate with GitHub Actions to automate your build and deployment workflows without replacing your existing setup. This guide explains how to set up and use GitHub Actions with your Ocuroot projects.
Setting Up GitHub Actions
Prerequisites
- A GitHub repository with GitHub Actions enabled
- An Ocuroot API key (stored as a GitHub secret named
OCUROOT_API_KEY
) - For sync triggers, a GitHub token with repository access (stored as
GH_TRIGGER_TOKEN
)
Workflow Files
You’ll need three workflow files in your .github/workflows
directory:
1. Review Workflow (review.yml
)
This workflow runs on pull requests to review code changes:
2. Deliver Workflow (deliver.yml
)
This workflow runs when code is merged to main:
3. Sync Workflow (sync.yml
)
This workflow handles deployments and can be triggered manually or via repository dispatch:
Common Elements
Each workflow includes:
- Ocuroot Binary Download: Downloads and installs the Ocuroot CLI
- Cache Configuration: Uses GitHub’s cache action to speed up builds
- Authentication: Uses the
OCUROOT_API_KEY
for API authentication
Setting Up Secrets
To use Ocuroot with GitHub Actions, you need to configure the OCUROOT_API_KEY
as a repository secret. Here’s how:
- Navigate to your GitHub repository
- Go to Settings > Secrets and variables > Actions
- Click New repository secret
- Set the name as
OCUROOT_API_KEY
- Paste your Ocuroot API key as the value
- Click Add secret
For more details on managing repository secrets, see GitHub’s official documentation on encrypted secrets.
If you’re setting up secrets for an organization:
- Organization-wide secrets can be configured at Organization Settings > Secrets and variables > Actions
- Environment-specific secrets can be configured in Repository Settings > Environments
Setting Up Sync Triggers
The ocuroot trigger-sync
command is used to automatically trigger the sync workflow after a successful delivery. This command uses GitHub’s API to trigger the sync workflow.
Configure Sync Trigger Logic
In your repo.ocu.star
file, define the trigger_sync function that will be called by the ocuroot trigger-sync
command:
This setup allows your delivery workflow to automatically trigger the sync workflow when needed, creating a seamless deployment pipeline.
Next Steps
- Configure your deployment triggers in
repo.ocu.star
- Learn more about Ocuroot’s CI integration