Skip to main content
Automate your Kodexa metadata deployments with kdx-sync-action - a GitHub Action that makes GitOps workflows simple, secure, and reliable.
GitHub Action Repository: kodexa-ai/kdx-sync-action
Philosophy: Branch determines deployment. One way to do it. Zero knobs, just config.

Quick Start

Deploy to Kodexa in 4 simple steps:

1. Define Branch and Tag Mappings

Create sync-config.yaml in your repository root:

2. Add Secrets

In GitHub repository settings → Secrets and variables → Actions:
  • KODEXA_PROD_API_KEY
  • KODEXA_STAGING_API_KEY
  • KODEXA_DEV_API_KEY
Use GitHub environments to add protection rules like required approvals for production deployments.

3. Create Workflow

Create .github/workflows/deploy.yml:

4. Push and Deploy

Done!
  • Push to main → production
  • Push to feature/new-thing → dev
  • Create tag v1.0.0 → production
  • Branch or tag determines deployment automatically

Understanding the Action

The kdx-sync-action is a composite GitHub Action that:
  1. Detects your environment (OS and architecture)
  2. Downloads kdx CLI (latest or pinned version)
  3. Caches the binary (faster subsequent runs)
  4. Auto-discovers configuration (sync-config.yaml, metadata directory)
  5. Runs deployment (kdx sync deploy with appropriate flags)
  6. Parses results (extracts statistics and sets outputs)
You don’t need to:
  • Install kdx CLI manually
  • Handle OS/architecture detection
  • Manage binary caching
  • Parse deployment output
The action handles all of this automatically.

Action Inputs

All inputs are optional:

Example with Inputs

Action Outputs

The action provides deployment statistics:

Using Outputs

Complete Workflow Examples

Multi-Environment Deployment

The standard pattern - branch determines everything:
With sync-config.yaml branch mappings:
No logic in the workflow! All routing is handled by sync-config.yaml.

Pull Request Validation with Preview

Validate changes and comment on PRs:

Production with Required Approval

Require manual approval before production deployment:
Setup required approvals:
  1. Go to Settings → Environments
  2. Create “production” environment
  3. Add required reviewers
  4. Optional: Add wait timer

Multi-Target Deployment

Deploy to multiple organizations:
The action automatically deploys to both organizations based on branch mapping.

Tag-Based Release Workflow

NEW in kdx CLI v0.5.0: Deploy using git tags for release-driven workflows.
Deploy production releases using semantic version tags:
Release workflow:
Benefits:
  • Immutable deployment references (tags don’t move like branches)
  • Clear release history in git
  • Rollback by creating tag from previous commit
  • Integration with GitHub Releases

Manual Deployment Override

NEW in kdx CLI v0.5.0: Manual control with --branch and --tag flags
Override automatic git detection for explicit deployment control:
Use cases:
  • Manual deployments without git operations
  • Testing deployment mappings
  • Rollback to specific version
  • Deploying from CI/CD without checkout

Scheduled Synchronization

Keep environments synchronized on a schedule:

Built-in Slack Notifications

Send rich deployment summaries to Slack automatically:
The Slack message includes:
  • 🚀 Deployment status (or 🔍 for dry runs)
  • Repository and branch information
  • Resource counts (created, updated, unchanged)
  • Direct link to the GitHub Actions run
Slack Setup:
  1. Create a Slack App at https://api.slack.com/apps
  2. Add chat:write OAuth scope
  3. Install to your workspace
  4. Copy Bot Token (xoxb-...) to SLACK_BOT_TOKEN secret
  5. Get channel ID (right-click channel → Copy link → extract ID)

GitHub Job Summary

Add a deployment summary directly to the workflow run:
The summary appears in the “Summary” tab and includes:
  • Resource counts (created, updated, unchanged)
  • Repository, branch, commit, and actor details
  • Environment breakdown (when available)
Combine all notification options:

Tag-Based Deployment

Deploy based on git tags instead of branches:
With tag_mappings in sync-config.yaml:

Manual Deployment with Parameters

Manual trigger with workflow inputs:

Migration from v1 to v2

What Changed

v1 (old): Manual environment logic in workflow
v2 (new): Branch mappings in configuration

Migration Steps

1

Move mappings to sync-config.yaml

Create branch mappings in your configuration:
2

Add environments to config

Define environments with API key references:
3

Simplify workflow

Replace complex workflow logic:
4

Update secrets

Replace old secret names with new format:
  • PROD_URL + PROD_TOKENKODEXA_PROD_API_KEY
  • STAGING_URL + STAGING_TOKENKODEXA_STAGING_API_KEY

Key Benefits of v2

  • Simpler workflows - No manual environment detection
  • Configuration-driven - Logic lives in sync-config.yaml
  • Less duplication - One workflow handles all branches
  • Easier maintenance - Change routing in config, not workflow
  • Auto-discovery - Finds sync-config.yaml automatically

Security Best Practices

1. Use GitHub Environment Secrets

Store API keys in environment-specific secrets:
Benefits:
  • Environment-specific secrets
  • Required approval rules
  • Wait timers
  • Deployment visibility
  • Complete audit trails

2. Never Hardcode Credentials

3. Require Approvals for Production

Configure environment protection rules:
  1. Settings → Environments
  2. Select “production”
  3. Enable “Required reviewers”
  4. Add team members
  5. Optional: Add wait timer

4. Use Branch Protection

Protect critical branches:
  1. Settings → Branches
  2. Add protection rule for main
  3. Require pull request reviews
  4. Require status checks to pass
  5. Require branch to be up to date

5. Limit Workflow Permissions

Use minimal necessary permissions:

6. Validate Before Deploying

Always use dry-run on PRs:

Development Workflow

Step-by-Step Process

1

Create feature branch

2

Make changes

3

Test locally

4

Commit and push

5

Open pull request

  • GitHub automatically runs dry-run validation
  • Review deployment preview in PR comments
  • Request team review
6

Merge and deploy

  • After approval, merge PR
  • GitHub Actions automatically deploys based on branch
  • Monitor workflow logs for results

Advanced: Using Manual kdx CLI

For most GitHub Actions use cases, use kdx-sync-action. Manual CLI is for local development and advanced debugging.

When to Use Manual CLI

  • Local development - Testing changes before committing
  • Advanced debugging - Need detailed control and output
  • Custom CI systems - Not using GitHub Actions
  • One-off operations - Manual syncs or migrations

Manual Installation in Workflows

If you need to use kdx CLI directly:
Note: kdx-sync-action handles all of this automatically with caching and cross-platform support.

Troubleshooting

Binary Download Failed

Issue: “Failed to download kdx from …” Solution: Specify a specific version:
Check available releases at kdx-cli-releases.

Branch Mapping Not Found

Issue: “No branch mapping found for branch ‘feature/xyz’” Solution 1 - Add fallback mapping:
Solution 2 - Use manual override in workflow:

Environment Variable Not Set

Issue: “Environment variable KODEXA_PROD_API_KEY not set” Fix: Ensure secret exists and is passed to action:
Verify secret:
  1. Settings → Secrets and variables → Actions
  2. Confirm secret name matches exactly
  3. Check environment restrictions if using GitHub environments

Authentication Failed

Issue: “Authentication failed” or “Invalid API key” Solutions:
  1. Verify secret value - Regenerate API key if needed
  2. Check key permissions - Ensure key has deployment access
  3. Test manually:

Deployment Validation Passed but Deployment Failed

Issue: Dry-run succeeds, but live deployment fails Common causes:
  • Resource dependencies don’t exist in target environment
  • Insufficient API key permissions
  • Environment-specific differences
Solution: Review error details in workflow logs and check resource dependencies.

Best Practices

1. Use Dry-Run on Pull Requests

Always validate before merging:

2. Use GitHub Environments for Protection

Separate credentials and add approval rules:

3. Add Deployment Summaries

Make results visible in workflow summaries:

4. Monitor Workflows

Set up notifications for failures:

5. Document Your Configuration

Add comments to sync-config.yaml:

6. Version Pin for Stability

Pin kdx-version for production workflows:

7. Test Branch Mappings Locally

Before committing configuration:

GitHub Action Repository Resources

The kodexa-ai/kdx-sync-action repository contains additional resources:
  • SETUP_GUIDE.md - Detailed setup instructions
  • examples/ - Complete workflow templates for common scenarios
  • action.yml - Full action definition with all inputs/outputs

Next Steps

Sync Configuration

Learn about sync-config.yaml structure and manifests

Resource Deployments

Complete deployment strategies and patterns

KDX CLI

Local CLI for development and testing

GitHub Action Repository

kdx-sync-action source and documentation