Description
Creates branch restrictions for a Bitbucket Cloud repository.
Input Schema
No input schema defined for this action.
Output Schema
| Property | Type | Description | Required | 
|---|---|---|---|
| json | string | The response from bitbucket cloud | |
| statusCode | number | The status code of the response | 
Usage Examples
Require approvals before merging to main
Creates a branch restriction that requires two approvals before merging into main. Use this right after creating the repository with publish:bitbucketCloud.
steps:
  - id: fetch-base
    name: Fetch service template
    action: fetch:template
    input:
      url: https://github.com/acme/templates/node-service
      targetPath: ./
  - id: require-approvals-main
    name: Require approvals on main
    action: bitbucketCloud:branchRestriction:create
    input:
      repoUrl: bitbucket.org?workspace=${{ parameters.workspace }}&repo=${{ parameters.repoSlug }}
      kind: require_approvals_to_merge
      matcher:
        kind: glob
        pattern: main
      value: ${{ parameters.requiredApprovals }}Prevent force pushes to release branches
Blocks force pushes to any release/* branches to protect release history. Use this after the repo is created, typically following publish:bitbucketCloud, to enforce guardrails on long-lived branches.
steps:
  - id: fetch-base
    name: Fetch base template
    action: fetch:template
    input:
      url: https://github.com/acme/templates/java-service
      targetPath: ./
  - id: protect-release-branches
    name: Block force pushes on release/*
    action: bitbucketCloud:branchRestriction:create
    input:
      repoUrl: bitbucket.org?workspace=${{ parameters.workspace }}&repo=${{ parameters.repoSlug }}
      kind: force
      matcher:
        kind: glob
        pattern: release/*