Last active
October 1, 2024 15:25
-
-
Save jameswilson/7779d07a0099edbbb16b4f59cf2c34ce to your computer and use it in GitHub Desktop.
BitBucket Pipelines deploy to Acquia via ACLI
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: php:8.3 | |
clone: | |
depth: full | |
pipelines: | |
branches: | |
develop: | |
- step: | |
script: | |
- scripts/ci/build.sh | |
- scripts/ci/test.sh | |
- scripts/ci/deploy.sh | |
services: | |
- docker | |
- mysql | |
caches: | |
- docker | |
- node | |
- composer | |
release/*: | |
- step: | |
script: | |
- scripts/ci/build.sh | |
- scripts/ci/test.sh | |
- scripts/ci/deploy.sh | |
services: | |
- docker | |
- mysql | |
caches: | |
- docker | |
- node | |
- composer | |
tags: | |
tags/*: | |
- step: | |
name: "Tag deployment" | |
script: | |
- scripts/ci/build.sh | |
- scripts/ci/test.sh | |
- scripts/ci/deploy.sh | |
services: | |
- docker | |
- mysql | |
caches: | |
- docker | |
- node | |
- composer | |
definitions: | |
services: | |
mysql: | |
image: mysql:5.7 | |
environment: | |
MYSQL_DATABASE: 'drupal' | |
MYSQL_USER: 'drupal' | |
MYSQL_ROOT_PASSWORD: 'root' | |
MYSQL_PASSWORD: 'drupal' |
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 | |
# Let's configure our linux environment | |
apt-get update && apt-get install -y apt-utils curl git mariadb-client unzip libxml2-dev libzip-dev zlib1g-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev libicu-dev nodejs npm rsync && apt-get autoremove | |
# Turn on php gd and zip. | |
docker-php-ext-install gd | |
docker-php-ext-install zip | |
docker-php-ext-install intl | |
docker-php-ext-install soap | |
# Let's set some defaults | |
pwd=$(pwd) | |
printf "Current folder is %s\n" "$pwd" | |
# If you want to build the css rather than commit it, | |
# you do it here: | |
printf "Installing GULP\n" | |
npm install -g gulp | |
cd docroot/themes/custom/themekit/src/gulp | |
printf "Installing node_modules\n" | |
npm install | |
printf "Running the build\n" | |
gulp default | |
cd $pwd | |
# Here is where we install all the composer modules. | |
printf "Installing composer.\n" | |
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
# No need to do this unless you want to run tests | |
# acli will run its own composer install when you deploy the artifact. | |
printf "Running composer install.\n" | |
composer install --no-dev --no-interaction --optimize-autoloader | |
# Using BLT? You should need some default settings. | |
#./vendor/bin/blt blt:init:settings | |
cp ./docroot/sites/default/default.services.yml ./docroot/sites/default/services.yml | |
# For Acquia we need to commit the vendor, contrib, and libraries | |
# so we need to ACLI. | |
cd /usr/local/bin/ | |
curl -OL https://github.com/acquia/cli/releases/latest/download/acli.phar | |
chmod 755 acli.phar | |
mv acli.phar acli | |
cd $pwd | |
# Here we have our database tasks. | |
mysql -u root -proot -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS drupal" | |
export PIPELINES_ENV=PIPELINES_ENV |
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 | |
acli auth:login --key ${ACQUIA_KEY} --secret ${ACQUIA_SECRET} | |
if [ -n "${BITBUCKET_REPO_SLUG}" ] ; then | |
git config --global user.email "[email protected]" | |
git config --global user.name "Bitbucket Pipelines" | |
git status | |
if [ $BITBUCKET_TAG ]; | |
then | |
tag=${BITBUCKET_TAG#*/} | |
#./vendor/bin/blt artifact:deploy --commit-msg "BLT:DEPLOY Tag ${tag}" --tag "${tag}" --no-interaction | |
acli --ansi --no-interaction --verbose push:artifact --destination-git-urls ${DEPLOY_URL} --destination-git-tag ${tag} --source-git-tag ${BITBUCKET_TAG} | |
fi; | |
if [ $BITBUCKET_BRANCH ]; | |
then | |
#./vendor/bin/blt -vvv artifact:deploy --commit-msg "BLT:DEPLOY ${BITBUCKET_BRANCH}" --branch "${BITBUCKET_BRANCH}" --no-interaction | |
acli --ansi --no-interaction --verbose push:artifact --destination-git-urls ${DEPLOY_URL} --destination-git-branch ${BITBUCKET_BRANCH}-build | |
fi; | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment