Skip to content

Part 6: Branch Deployments

Deploy feature branches side-by-side with your main deployment to test changes in a real environment before merging.

What you'll learn

  • Building and deploying from a feature branch
  • Running branch deployments alongside the main deployment
  • Comparing branch and main URLs side-by-side
  • Cleaning up branch deployments after merging

What you'll need

  • A running deployment from Part 5
  • A feature branch in your Git repository

Create a feature branch

Start a feature branch that adds a priority field to todos:

git checkout -b feature/priority

Add a priority migration

-- backend/src/main/resources/db/migration/V2__add_priority.sql
ALTER TABLE todos ADD COLUMN priority VARCHAR(10) DEFAULT 'normal'
    CHECK (priority IN ('low', 'normal', 'high', 'urgent'));

Update the entity

// backend/src/main/java/com/example/todo/Todo.java (add to existing fields)
@Column(length = 10)
private String priority = "normal";

public String getPriority() { return priority; }
public void setPriority(String priority) { this.priority = priority; }

Update the frontend

Add a priority selector to the todo form:

<!-- frontend/src/App.vue (updated form section) -->
<form @submit.prevent="addTodo">
  <input v-model="newTitle" placeholder="What needs doing?" />
  <select v-model="newPriority">
    <option value="low">Low</option>
    <option value="normal">Normal</option>
    <option value="high">High</option>
    <option value="urgent">Urgent</option>
  </select>
  <button type="submit">Add</button>
</form>

Add the reactive state:

const newPriority = ref('normal')

async function addTodo() {
  if (!newTitle.value.trim()) return
  await fetch(`${API_URL}/api/todos`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ title: newTitle.value, priority: newPriority.value })
  })
  newTitle.value = ''
  newPriority.value = 'normal'
  await fetchTodos()
}

Push and build the branch

git add -A && git commit -m "feat: add priority field to todos"
git push -u origin feature/priority

Build from the feature branch:

mecca build trigger -g git@github.com:yourorg/todo-app.git -b feature/priority

Branch builds

The -b flag tells AppMecca's build service which branch to clone. The resulting images are tagged with that branch's commit hash. Branch builds do not affect your main deployment.

A deploy is queued automatically after a successful build, so the command above already deploys the branch. Pass --no-deploy if you want to build only.

Deploy the branch

If you built with --no-deploy, deploy the feature branch alongside the existing main deployment:

mecca app deploy todo-app -b feature/priority

This creates a separate deployment with its own hostnames. Your main deployment continues running undisturbed.

Compare side-by-side

mecca queue status takes the action ID printed by the build or deploy. To see everything in flight for the app, use mecca queue list:

mecca queue list -a todo-app
mecca queue status <action-id>
mecca app show todo-app          # per-service status, URLs, and branches

You now have two sets of URLs. The sanitised branch name is inserted between the app slug and the service name (/ becomes -), and main contributes no segment at all:

Main:     https://todo-app-frontend-yourgroup.dev.example.com
Branch:   https://todo-app-feature-priority-frontend-yourgroup.dev.example.com

Main:     https://todo-app-backend-yourgroup.dev.example.com
Branch:   https://todo-app-feature-priority-backend-yourgroup.dev.example.com

Open both frontend URLs in your browser. The branch version has the priority dropdown; the main version does not.

Database isolation

Every branch gets its own, initially empty database — the name is derived per branch, so main and feature/priority never share data. Your V2 Flyway migration runs against the branch's own schema and cannot break the main deployment. Nothing is copied across from main; drives and buckets are per-branch too.

Set branch-specific environment variables

mecca var set writes to every branch unless you narrow it with -b. To override config for the branch deployment only:

mecca var set todo-app PUBLIC_APP_TITLE="Todo App (Priority Beta)" -b feature/priority
mecca app deploy todo-app -b feature/priority --no-build

Iterate quickly

Rebuilding the branch also redeploys it, so a single command covers the edit-test loop:

mecca build trigger -g git@github.com:yourorg/todo-app.git -b feature/priority

Review builds

List builds to see both main and branch:

mecca build list --app todo-app

The output shows each build with its branch, image tag, status, and time.

Clean up the branch deployment

Once the feature is merged, remove the branch deployment:

mecca app undeploy todo-app -b feature/priority --force

To also delete the branch's build artifacts and built images:

mecca app undeploy todo-app -b feature/priority --force --purge

Purge is permanent

The --purge flag deletes that branch's images from AppMecca's image registry along with its build records and registry data. Only use it after you are certain the branch work is complete.

Merge and redeploy main

After merging to main:

git checkout main
git merge feature/priority
git push
mecca build trigger -g git@github.com:yourorg/todo-app.git

The main deployment now includes the priority feature, and the branch deployment is gone.

Branch deployment workflow summary

1. Create branch           git checkout -b feature/X
2. Push changes            git push -u origin feature/X
3. Build + deploy branch   mecca build trigger -g <url> -b feature/X
4. Test and iterate        mecca build trigger -g <url> -b feature/X
5. Merge to main           git merge feature/X
6. Clean up branch         mecca app undeploy todo-app -b feature/X --force --purge
7. Rebuild main            mecca build trigger -g <url>

Command reference

Command Purpose
mecca build trigger -g <url> -b <branch> Build a branch (auto-deploys)
mecca build trigger -g <url> -b <branch> --no-deploy Build only
mecca app deploy <app> -b <branch> Deploy a branch
mecca queue list -a <app> List the app's in-flight actions
mecca queue status <action-id> Check one action
mecca var set <app> KEY=val -b <branch> Set a variable on one branch
mecca app undeploy <app> -b <branch> --force Remove branch deployment
mecca app undeploy <app> -b <branch> --force --purge Remove and purge artifacts

What's next

In Part 7: Internal Service Discovery, you will add an auth service and see how AppMecca services address each other.