Created: 2019.08.08
This will be used to authorise interactions with the Sitehost server.
- Open repository in Bitbucket
- Scroll down to Pipelines, then click SSH keys
- Click Generate keys
- Click Copy Public key
- Log into Sitehost
- Choose the correct account from the dropdown
- Click SSH Keys
- Click Add SSH Key
- Enter a Label: Bitbucket deployment to Production
- Paste in the Public Key
- Click Add SSH Key
- Click Containers, then SSH & SFTP
- Take a note of the User name
- Take a note of the Server IP
- Click the 3 dots to Manage the existing user
- Tick the Bitbucket deployment to Production checkbox under SSH Keys
- Click Save changes
- Wait until the spinner at the end of the table row is replaced with the 3 dots menu icon (The SSH user is now in the process of being updated message does not disappear).
- Open repository in Bitbucket
- Scroll down to Pipelines, then click SSH keys
- Under Known Hosts, enter the Server IP noted in step 2
- Click Fetch
- Click Add (or similar)
These will be used in the Pipeline, trigged by commits to the repository.
- Scroll down to Pipelines, then click Deployments
- Click the desired environment heading (e.g. Production) to reveal additional UI
- Scroll down to Variables, then click Add
- Create SFTP_USERNAME and populate it with the User name from step 2
- Create SFTP_SERVER and populate it with the Server IP from step 2
- Create SFTP_PATH and format it as follows (for a WordPress site running in a Sitehost 'container'): container/application/public/wp-content/themes/theme-name
Create or update the bitbucket-pipelines.yml file in the repo root:
# Theme deployment.
# Deployment $VARIABLES are managed in Bitbucket
#
# @package TwentynineteenDotherightthing
# @since 0.1.0
# @uses https://bitbucket.org/atlassian/sftp-deploy/src/master/
#
# pipelines: marks the beginning of all your pipeline definitions.
# default: contains the steps that will run on every push.
# step: each step starts a new Docker container that includes a clone of your repository, and then runs the contents of your script section inside it.
# script: a list of commands that are executed in sequence.
image: frozentech/bitbucket-pipelines-php-mysql
pipelines:
# string required here, need to increment for 4.* etc
3.*:
- step:
name: Build theme
script:
# ...
# Make artifacts available in Pipeline UI
artifacts:
# The Gulpfile pipes the contents of the distDir into a zip
# then renames this to release-n.n.n.zip
# then outputs it to the build root.
# Gulp handles this, for compatibility with Travis.
# Note: * is used, as ${BITBUCKET_TAG} causes the artifact to disappear
- wpdtrt-dbth/**
- release-*.zip
- step:
name: Deploy theme to server
deployment: production
script:
# SFTP deployment to server
# Rsync only transfers updated files
- pipe: atlassian/rsync-deploy:0.3.1
variables:
USER: $SFTP_USERNAME
SERVER: $SFTP_SERVER
REMOTE_PATH: $SFTP_PATH
LOCAL_PATH: wpdtrt-dbth/**