Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drupal → Bitbucket Automation

A Drupal 7 module that hooks into the project-create event and automatically provisions a private Bitbucket repository with the agency workflow already enforced: branch protection, approval rules, push restrictions, and PR webhooks.

Case study: 5am.dev/work/drupal-bitbucket

What it does

When a PM creates a "site" content type node in the Drupal intranet, the module:

  1. Authenticates against Bitbucket using OAuth2 client credentials (no service-user impersonation, no personal access tokens).
  2. Slugifies the project title and creates a private repository.
  3. Adds a PR webhook back to the intranet bot, subscribing to every relevant pull-request event.
  4. Creates three standard branches: master, staging, develop.
  5. Applies branch restrictions:
    • Push-restricted to the admin group only
    • Two approvals required for any merge to master or staging
    • Delete-protected so nobody can wipe a main branch by accident
    • Per-group merge permissions (developer, junior, reviewer)

The headline outcome: junior developers stopped occasionally landing in production by accident — not because they got better at the rules, but because the rules were finally in the path.

Stack

PHP · Drupal 7 · Bitbucket REST API v2 · OAuth2 (client credentials) · Symfony Dotenv · php-curl-class

Install

composer install

Copy .env.example to .env and fill in:

  • CLIENT_ID, CLIENT_SECRET — your Bitbucket OAuth app credentials
  • USER — the Bitbucket workspace
  • ADMINISTER_GROUP, DEVELOPER_GROUP, JUNIOR_GROUP, REVIEWER_GROUP — group slugs
  • AUTH — shared secret for the webhook callback

Enable the module in Drupal at admin/modules.

Status

Drupal 7 reached end-of-life in January 2025, so this module is preserved as a portfolio artifact. The pattern (encode the workflow, hook it into project creation, never trust a human to remember) would translate cleanly to a GitHub Actions workflow or a small webhook receiver in front of any modern repo host.

Author

Sam Ayres

About

Drupal integration with Bitbucket to configure organization work spaces.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors