Skip to content

Instantly share code, notes, and snippets.

@khoipro
Created June 24, 2019 09:30
Show Gist options
  • Save khoipro/4df13fe0231d37a9bd8ae5493c6d7f97 to your computer and use it in GitHub Desktop.
Save khoipro/4df13fe0231d37a9bd8ae5493c6d7f97 to your computer and use it in GitHub Desktop.
Deploy from GitLab to WPEngine (Tested)
stages:
- deploy_dev
- deploy_staging
- deploy_live
before_script:
- 'which ssh-agent || ( apk add --update openssh )'
- apk add --update bash
- apk add --update git
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY"
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
Deploy Dev:
stage: deploy_dev
script:
- git remote add dev $WPENGINE_DEV_GIT
- "git checkout -b dev"
- "git push dev HEAD:master --force"
only:
- develop
Deploy Staging:
stage: deploy_staging
script:
- git remote add staging $WPENGINE_STAGING_GIT
- "git checkout -b staging"
- "git push staging HEAD:master --force"
only:
- master
Deploy Live:
stage: deploy_live
when: manual
script:
- git remote add live $WPENGINE_LIVE_GIT
- "git checkout -b live"
- "git push live HEAD:master --force"
only:
- tags
@stalwil
Copy link

stalwil commented Apr 3, 2024

@khoipro - i know this was 5 years ago...but i was wondering...if i create this file and push it to my repo (dev branch) in gitlab...how does it know to only deploy to my dev environment in WPEngine?

Process DEV

  1. Push to dev branch (gitlab.com)
  2. Deploy to dev environment (wpengine)

Process STAGE

  1. Push to stage branch (gitlab.com)
  2. Deploy to stage environment (wpengine)

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