Enhanced Deployment Control: New allow_deployments API Flag

February 6, 2023

Fine-grained deployment control is essential for modern DevOps workflows. Our Branch API now includes an enhancement that enables you to build smarter deployment scripts and automation workflows.

What’s New

Branch API responses now include the allow_deployments flag, enabling your DevOps scripts and CI/CD pipelines to make intelligent deployment decisions based on current permissions.

API Response Example

{
  "frozen": false,
  "allow_deployments": true,
  "branch": "main",
  "repository": "my-app",
  "timezone": "Eastern Time (US & Canada)",
  "next_freeze_at": "1666341060",
  "next_unfreeze_at": "1666341502"
}

Smart Deployment Control

Independent Control Settings

The allow_deployments flag operates independently from the frozen status, giving you nuanced control over your deployment pipeline:

  • frozen: false, allow_deployments: true - Normal operations
  • frozen: true, allow_deployments: false - Complete lockdown
  • frozen: false, allow_deployments: false - Allow merges but block deployments
  • frozen: true, allow_deployments: true - Block merges but allow emergency deployments

Teams using Slack can easily toggle the allow_deployments flag without affecting the frozen status.

Slack allow deployments

Built for DevOps Automation

This enhancement is helpful for DevOps teams who want to integrate deployment permissions into their automated workflows and scripts.

Your deployment scripts can now check the allow_deployments flag before attempting deployments, preventing unnecessary failures and providing better pipeline reliability.

Real-World Use Cases

Maintenance Windows

During scheduled maintenance, you might want to:

  1. Allow critical hotfixes to be merged
  2. Block all deployments until maintenance is complete
# Block deployments but allow merges during maintenance
curl -X POST "https://www.mergefreeze.com/api/branches/your-org/your-repo/main?access_token=your_api_token" -d "frozen=false&allow_deployments=false&note=Maintenance window"

Emergency Response

In production incidents, you might need to:

  1. Freeze all new changes to prevent complications
  2. Allow emergency deployments for hotfixes
# Freeze merges but allow emergency deployments
curl -X POST "https://www.mergefreeze.com/api/branches/your-org/your-repo/main?access_token=your_api_token" -d "frozen=true&allow_deployments=true&note=Emergency hotfix mode"

Release Coordination

During complex releases:

  1. Freeze merges to prevent new features
  2. Control deployment timing independently

Integration Benefits

Smarter DevOps Scripts

Your deployment scripts can now check permissions before attempting deployments:

#!/bin/bash
# Smart deployment script example
RESPONSE=$(curl -s "https://www.mergefreeze.com/api/branches/myorg/myrepo/main?access_token=$TOKEN")
ALLOW_DEPLOYMENTS=$(echo $RESPONSE | jq -r '.allow_deployments')

if [ "$ALLOW_DEPLOYMENTS" = "true" ]; then
  echo "✅ Deployments allowed - proceeding with deployment"
  # Run your deployment commands here
  ./deploy.sh
else
  echo "⚠️ Deployments blocked - skipping deployment"
  exit 0
fi

CI/CD Pipeline Integration

Build intelligent CI/CD pipelines that respect deployment permissions:

# GitHub Actions example
- name: Check deployment permissions
  id: check-deploy
  run: |
    RESPONSE=$(curl -s "https://www.mergefreeze.com/api/branches/${{ github.repository_owner }}/${{ github.event.repository.name }}/main?access_token=${{ secrets.MERGE_FREEZE_TOKEN }}")
    ALLOW_DEPLOYMENTS=$(echo $RESPONSE | jq -r '.allow_deployments')
    echo "allow_deployments=$ALLOW_DEPLOYMENTS" >> $GITHUB_OUTPUT    

- name: Deploy to production
  if: steps.check-deploy.outputs.allow_deployments == 'true'
  run: |
    echo "Deploying to production..."
    # Your deployment steps here    

Next Steps

For complete API documentation and examples:

The allow_deployments flag gives your DevOps scripts the intelligence they need to make deployment decisions automatically, reducing failed deployments and improving pipeline reliability. Integrate it into your workflows today! 🚀