Skip to content

Instantly share code, notes, and snippets.

@keepitsimple
Last active August 26, 2024 00:06
Show Gist options
  • Select an option

  • Save keepitsimple/41f41d2c768cf94c8b96db9c27c2dda8 to your computer and use it in GitHub Desktop.

Select an option

Save keepitsimple/41f41d2c768cf94c8b96db9c27c2dda8 to your computer and use it in GitHub Desktop.
Bitbucket pipeline to sync / copy code commits to GitHub. How to sync Bitbucket repo to GitHub
image: alpine/git:1.0.26
definitions:
services:
docker:
memory: 1024
steps:
- step: &Push-to-GitHub
name: Push code changes to GitHub
services:
- docker
caches:
- docker
script:
- git remote add github "[email protected]:[yourname]/[your repo].git"
- git checkout $BITBUCKET_BRANCH
- git pull
- git push github $BITBUCKET_BRANCH
pipelines:
branches:
master:
- step: *Push-to-GitHub
sandbox:
- step: *Push-to-GitHub
staging:
- step: *Push-to-GitHub
production:
- step: *Push-to-GitHub
@keepitsimple
Copy link
Copy Markdown
Author

It needs to generate SSH key pair in your BitBucket account and to register the public ssh key in your GitHub repo settings as Deployment key ( set [x] for write access)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment