- Add Docker image build and push workflow (multi-arch: amd64, arm64) - Add Helm chart release workflow with GitHub Pages publishing - Add comprehensive release workflow for version tags - Add PR validation workflow (tests, linting, validation) - Update Chart.yaml and values.yaml with GitHub URLs - Update image repository to use ghcr.io - Add detailed CI/CD documentation and setup guides Workflows provide: - Automated Docker image builds to GitHub Container Registry - Automated Helm chart releases to GitHub Pages - Complete release automation with version tagging - PR validation with tests and linting Helm repository will be available at: https://vegardengen.github.io/unifi-network-operator Docker images available at: ghcr.io/vegardengen/unifi-network-operator
7.0 KiB
GitHub Workflows Documentation
This directory contains GitHub Actions workflows for automating the build, test, and release process of the UniFi Network Operator.
Workflows Overview
1. Docker Build and Push (docker-build-push.yaml)
Triggers:
- Push to
mainbranch - Push to
feature/**branches - Push of tags starting with
v* - Pull requests to
main - Manual dispatch
What it does:
- Runs Go tests with coverage
- Builds multi-architecture Docker images (amd64, arm64)
- Pushes images to GitHub Container Registry (ghcr.io)
- Creates tags based on branch/tag names
Image naming:
ghcr.io/vegardengen/unifi-network-operator:main- Latest from main branchghcr.io/vegardengen/unifi-network-operator:feature-xyz- Feature branch buildsghcr.io/vegardengen/unifi-network-operator:v1.0.0- Version tagsghcr.io/vegardengen/unifi-network-operator:latest- Latest stable release
2. Helm Chart Release (helm-release.yaml)
Triggers:
- Push to
mainbranch with changes inhelm/directory - Manual dispatch
What it does:
- Packages the Helm chart
- Creates GitHub releases for chart versions
- Publishes chart to GitHub Pages
- Updates the Helm repository index
Chart repository: https://vegardengen.github.io/unifi-network-operator
3. Full Release (release.yaml)
Triggers:
- Push of version tags (e.g.,
v1.0.0,v1.2.3) - Manual dispatch with version input
What it does:
- Builds and pushes multi-arch Docker images
- Updates Chart.yaml and values.yaml with release version
- Packages and releases Helm chart
- Creates GitHub release with release notes
- Attaches Helm chart package to release
Pre-release detection: Automatically marks releases as pre-release if tag contains alpha, beta, or rc
4. PR Validation (pr-validation.yaml)
Triggers:
- Pull requests to
mainbranch - Manual dispatch
What it does:
- Validates Go code formatting
- Runs
go vet - Executes tests with race detection
- Uploads coverage to Codecov
- Lints Helm chart
- Validates rendered Kubernetes manifests
- Test builds Docker image
Setup Requirements
1. Enable GitHub Pages
- Go to repository Settings → Pages
- Source: Deploy from a branch
- Branch:
gh-pages// (root) - Save
The Helm chart will be available at: https://vegardengen.github.io/unifi-network-operator
2. Enable GitHub Packages
GitHub Container Registry is enabled by default. Images are automatically pushed to:
ghcr.io/vegardengen/unifi-network-operator
To pull images:
docker pull ghcr.io/vegardengen/unifi-network-operator:latest
3. Configure Secrets (Optional)
The workflows use GITHUB_TOKEN which is automatically provided. Additional secrets you might want to add:
CODECOV_TOKEN- For uploading coverage reports (optional)
4. Branch Protection (Recommended)
Configure branch protection for main:
- Go to Settings → Branches → Branch protection rules
- Add rule for
main - Enable:
- Require pull request reviews
- Require status checks to pass (select PR Validation workflow)
- Require branches to be up to date
Usage
Creating a Release
Method 1: Using Git Tags (Recommended)
# Create and push a version tag
git tag -a v1.0.0 -m "Release v1.0.0"
git push github v1.0.0
This automatically:
- Builds Docker images for
v1.0.0andlatest - Packages Helm chart with version
1.0.0 - Creates GitHub release
- Publishes to Helm repository
Method 2: Manual Dispatch
- Go to Actions → Release workflow
- Click "Run workflow"
- Enter the version tag (e.g.,
v1.0.0) - Click "Run workflow"
Installing from the Helm Repository
Once the release workflow completes:
# Add the Helm repository
helm repo add unifi-network-operator https://vegardengen.github.io/unifi-network-operator
# Update repository cache
helm repo update
# Install the operator
helm install unifi-network-operator unifi-network-operator/unifi-network-operator \
--namespace unifi-network-operator-system \
--create-namespace \
--set unifi.url="https://your-unifi-controller:8443" \
--set unifi.password="your-password"
Using Development Builds
Feature branch builds are automatically pushed:
# Use a specific feature branch build
helm install unifi-network-operator ./helm/unifi-network-operator \
--set image.repository=ghcr.io/vegardengen/unifi-network-operator \
--set image.tag=feature-xyz
Workflow Files
docker-build-push.yaml- Docker image CI/CDhelm-release.yaml- Helm chart publishingrelease.yaml- Complete release processpr-validation.yaml- PR checkscr.yaml- Chart Releaser configuration
Versioning Strategy
Docker Images
latest- Latest stable release from main branchvX.Y.Z- Specific version tagX.Y.Z- Version without 'v' prefixX.Y- Major.minor versionX- Major version onlymain- Latest commit on main branchfeature-name- Feature branch builds
Helm Charts
- Chart version follows semantic versioning (X.Y.Z)
- AppVersion matches Docker image tag
- Both are automatically updated during release
Troubleshooting
Docker Build Fails
Check:
- Dockerfile syntax
- Go dependencies in go.mod
- Build context includes all necessary files
Helm Release Fails
Check:
- Chart.yaml is valid
- All template files are valid YAML
- No syntax errors in templates
- Version in Chart.yaml is unique
GitHub Pages Not Updating
- Check workflow completed successfully
- Verify
gh-pagesbranch exists - Check Pages is enabled in repository settings
- Wait a few minutes for CDN propagation
Images Not Accessible
Public images require:
- Repository → Settings → Packages
- Find the package
- Package settings → Change visibility → Public
Best Practices
-
Always test locally first:
make helm-lint make helm-template docker build -t test . -
Use semantic versioning:
- Major (X): Breaking changes
- Minor (Y): New features, backward compatible
- Patch (Z): Bug fixes
-
Create release notes:
- Describe what changed
- Highlight breaking changes
- Document upgrade path
-
Test releases in a dev environment:
- Use pre-release tags (
v1.0.0-beta1) - Validate before promoting to stable
- Use pre-release tags (
Monitoring
Check Workflow Status
- Go to repository → Actions
- View workflow runs
- Check logs for failures
View Published Artifacts
- Docker images: https://github.com/vegardengen/unifi-network-operator/pkgs/container/unifi-network-operator
- Helm charts: https://github.com/vegardengen/unifi-network-operator/releases
- Chart repository: https://vegardengen.github.io/unifi-network-operator
Support
For issues with workflows:
- Check the Actions tab for detailed logs
- Review the workflow YAML files
- Consult GitHub Actions documentation
- Open an issue in the repository