Last active
April 18, 2022 18:34
-
-
Save kaanra/ba5d8ec2f50238225d46b9c96cdc83fe to your computer and use it in GitHub Desktop.
[Bitbucket Pipelines Git-ftp] #git #bitbucket #pipelines
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
# https://www.savjee.be/2016/06/Deploying-website-to-ftp-or-amazon-s3-with-BitBucket-Pipelines/ | |
# https://github.com/git-ftp/ | |
# | |
# If using plain FTP, switch sftp to ftp and remove --insecure flag | |
# | |
# $VARIABLES: These are bitbucket repo variables. Set under Your Bitbucket Repo > Settings > Repository variables | |
# | |
# $SFTP_HOST example: sftp://myhostnamehere/public_html/staging | |
# | |
# --insecure flag: Set due to error "curl failed to verify the legitimacy of the server and therefore could not | |
# establish a secure connection to it" | |
image: bitnami/git | |
pipelines: | |
# PIPELINES TRIGGERED ON BRANCH PUSHES | |
branches: | |
# Staging Deployment | |
develop: # branch name that triggers the pipeline | |
- step: | |
name: Deploy to staging | |
deployment: staging | |
script: | |
- apt-get update | |
- apt-get -qq install git-ftp | |
- git ftp push --user $SFTP_STAG_USERNAME --passwd $SFTP_STAG_PASSWORD sftp://$SFTP_STAG_HOST -v --insecure | |
# PIPELINES TRIGGERED MANUALLY IN BITBUCKET | |
# triggers under Your Bitbucket Repo > Pipelines > Run pipeline | |
custom: | |
# Staging Catchup | |
# creates/updates the .git-ftp.log file on the remote host | |
staging-catchup: # name that is displayed in the bitbucket gui | |
- step: | |
name: Catchup git-ftp on staging | |
deployment: staging | |
script: | |
- apt-get update | |
- apt-get -qq install git-ftp | |
- git ftp catchup --user $SFTP_STAG_USERNAME --passwd $SFTP_STAG_PASSWORD sftp://$SFTP_STAG_HOST -v --insecure | |
# Production Deployment | |
# make sure to select the 'master' branch under Run pipeline | |
production-deployment: | |
# Get a list of files that for deployment | |
# --dry-run nothing is uploaded, files in .git-ftp-ignore should not be listed | |
- step: | |
name: Get deploy sync list | |
script: | |
- apt-get update | |
- apt-get -qq install git-ftp | |
- git ftp push --dry-run --user $SFTP_PROD_USERNAME --passwd $SFTP_PROD_PASSWORD sftp://$SFTP_PROD_HOST -v --insecure | |
# Manually trigger the deployment step | |
# trigger if the sync list in the previous step looked good | |
- step: | |
name: Deploy to production | |
deployment: production | |
trigger: manual | |
script: | |
- apt-get update | |
- apt-get -qq install git-ftp | |
- git ftp push --user $SFTP_PROD_USERNAME --passwd $SFTP_PROD_PASSWORD sftp://$SFTP_PROD_HOST -v --insecure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment