Docs
/

Get started

Deploy from Bitbucket

Mirror a Bitbucket repository to GitHub with a pipeline, and Dcubix deploys every push.

Dcubix builds from GitHub. Until native Bitbucket support arrives, a Bitbucket pipeline can copy every push to a private GitHub repository, and Dcubix deploys from there.

Set up the mirror

  1. Create an empty private repository on GitHub. Don’t add a README or licence: the mirror overwrites the branch.

  2. Create an SSH key in Bitbucket. In the Bitbucket repository, open Repository settings → Pipelines → SSH keys and generate a key pair. Under Known hosts, add github.com and fetch its fingerprint.

    If Pipelines isn’t enabled for the repository yet, enable it under Repository settings → Pipelines → Settings.

  3. Give the key write access on GitHub. In the GitHub repository, open Settings → Deploy keys, add the public key from Bitbucket and tick Allow write access. A deploy key works for this one repository only.

  4. Add the pipeline. Commit this bitbucket-pipelines.yml to the root of the Bitbucket repository, with ORG/REPO replaced by the GitHub repository:

    YAML
    pipelines:
      default:
        - step:
            name: Mirror to GitHub
            clone:
              depth: full
            script:
              - git push --force git@github.com:ORG/REPO.git HEAD:refs/heads/$BITBUCKET_BRANCH
  5. Create the app. Install the Dcubix GitHub App on the GitHub repository, then create the app from it as in the Quickstart.

From now on, each push to Bitbucket runs the pipeline, which pushes the same commit to the branch of the same name on GitHub. Dcubix deploys it when that branch is the app’s branch.

Why depth: full

Bitbucket clones only the most recent commits by default. GitHub rejects a push from a shallow clone like that, because the commits it would need are missing. depth: full clones the whole history, so the push succeeds.

Things to know

  • default runs for every branch that has no pipeline of its own, so every branch is mirrored. Only the app’s branch deploys.
  • Tags are not mirrored by this pipeline.
  • If a run fails, nothing reaches GitHub and nothing deploys. The pipeline’s log in Bitbucket shows why.