This document outlines the CI/CD workflows set up for the DuckDB-Spawn project.
The project uses GitHub Actions for CI/CD with deployments to Koyeb for hosting. We have the following environments:
- Production: Main application deployed from the
main
branch - Staging: Testing environment deployed from the
dev
branch - Preview: Temporary environments for pull requests and feature development
Handles continuous integration tasks including:
- Code formatting
- Linting
- Testing
- Building the Docker image
Triggered on push to main
and dev
branches, and on all pull requests to main
.
Deploys the application to the production environment on Koyeb:
- Builds and pushes the Docker image
- Deploys the image to Koyeb
- Tags the image as
latest
Triggered on push to the main
branch.
Deploys the application to the staging environment on Koyeb:
- Builds and pushes the Docker image with the
staging
tag - Deploys the image to Koyeb staging environment
Triggered on push to the dev
branch.
Creates temporary preview environments for pull requests:
- Builds and pushes a Docker image for the feature branch
- Deploys to a dedicated preview environment on Koyeb
- Comments on the PR with the deployment URL
Triggered on new and updated pull requests to main
and dev
branches.
Removes temporary preview environments when branches are deleted:
- Cleans up Koyeb deployments
- Can be triggered manually for cleanup
Triggered on branch deletion events.
The following secrets need to be configured in GitHub:
DOCKER_HUB_USERNAME
: Your Docker Hub usernameDOCKER_HUB_ACCESS_TOKEN
: Access token for Docker HubKOYEB_API_TOKEN
: API token for accessing Koyeb servicesDOCKER_REPO_SECRET
: Secret for accessing private Docker repositories
The /infrastructure/pulumi
directory contains Pulumi infrastructure code for alternative deployment options:
- Docker-based local deployment
- Koyeb CLI deployment
- Koyeb native provider deployment
- Branch Protection: Enable branch protection for
main
anddev
branches - PR Reviews: Require pull request reviews before merging
- Environment Deployment: Use GitHub Environments for deployment approval
- Secrets Management: Store all sensitive information in GitHub Secrets
If you encounter errors related to Docker registry authentication, such as:
Error while checking the validity of the docker image: The image "docker.io/****/duckdb-spawn:COMMIT_HASH" was not found.
Try the following steps:
- Run Debug Workflow: Use the
debug-docker.yml
workflow to check Docker registry access - Verify Secrets: Ensure
DOCKER_HUB_USERNAME
andDOCKER_HUB_ACCESS_TOKEN
are correctly set in GitHub Secrets - Check Image Tags: Verify that your Docker image is being correctly tagged and pushed
- Koyeb Secret: Make sure the Koyeb Docker registry secret is correctly configured
If you see errors like:
jq: error (at <stdin>:1): Cannot iterate over null (null)
This usually means:
- The Docker Hub repository doesn't exist yet - the workflow should now auto-create it
- Your Docker Hub credentials don't have permission to access or create repositories
- The Docker Hub API might be experiencing issues
To resolve these problems:
- Run the
debug-docker.yml
workflow which will try to create the repository - Check that your Docker Hub access token has appropriate permissions (read, write, delete)
- If auto-creation fails, manually create the repository in the Docker Hub web interface
If deployments to Koyeb fail:
- API Token: Ensure your
KOYEB_API_TOKEN
is valid and has the correct permissions - Service Configuration: Verify the service configuration parameters in the workflow files
- Resource Limits: Check if you've hit any resource limits in your Koyeb account
- Logs: Review the Koyeb service logs for more detailed error information
For detailed Koyeb deployment troubleshooting, see the Koyeb Deployment Guide.
Our deployment workflow now includes:
- Multi-stage verification of Docker images
- Multiple deployment methods with fallbacks if the primary method fails:
- GitHub Action-based deployment
- Direct CLI deployment
- Service update method
- Detailed error reporting at each stage
- Registry authentication optimization to resolve common image access issues
This approach ensures maximum reliability for deployments to both staging and production environments.
- Linter Errors: If you see YAML linter errors about environment values, remove the environment line if it's not needed
- Secret Access: If secret access fails, verify that secrets are available to the workflow
- Action Versions: Ensure you're using the latest versions of the GitHub Actions
- Checkout Token Error: If you see
Error: Input required and not supplied: token
withactions/checkout@v4
, ensure you addwith: token: ${{ secrets.GITHUB_TOKEN }}
to the checkout step.