Last active
June 29, 2022 04:54
-
-
Save angry-dan/6ae18554ed642999c6952803139792aa to your computer and use it in GitHub Desktop.
A small script to run as part of your bitbucket pipelines to deploy code from the Bitbucket repository into an external git repository, tested with Acquia so far. Configure SSH keys and the DEPLOY_URL variable in the BitBucket UI to make it work. Assumes a Drupal install in /docroot and node stuff in /app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:7.4 | |
# Yes, you do need this in order to be able to do onward pushes. | |
clone: | |
depth: full | |
pipelines: | |
default: | |
# Don't forget caches as well. | |
- step: | |
script: | |
- ENVIRONMENT=prod make build | |
- ENVIRONMENT=prod make deploy | |
# Tags don't run on the `default` pipeline so they need one for themselves. | |
tags: | |
'*': | |
- step: | |
script: | |
- ENVIRONMENT=prod make build | |
- ENVIRONMENT=prod make deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
set -e | |
if [ -n "${BITBUCKET_REPO_SLUG}" ] ; then | |
git config user.email "[email protected]" | |
git config user.name "Bitbucket Pipelines" | |
git remote add deploy $DEPLOY_URL; | |
# If the module is -dev, a .git file comes down. | |
find docroot -type d -name .git -exec rm -rf {} \; | |
SHA=$(git rev-parse HEAD) | |
GIT_MESSAGE="Deploying ${SHA}: $(git log -1 --pretty=%B)" | |
git add --force --all | |
# Exclusions: | |
git reset -- app/node_modules | |
git status | |
git commit -qm "${GIT_MESSAGE}" | |
if [ $BITBUCKET_TAG ]; | |
then | |
git tag --force -m "Deploying tag: ${BITBUCKET_TAG}" ${BITBUCKET_TAG} | |
git push deploy refs/tags/${BITBUCKET_TAG} | |
fi; | |
if [ $BITBUCKET_BRANCH ]; | |
then | |
git push deploy --force refs/heads/$BITBUCKET_BRANCH; | |
fi; | |
git reset --mixed $SHA; | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment