Created
June 24, 2019 09:30
-
-
Save khoipro/4df13fe0231d37a9bd8ae5493c6d7f97 to your computer and use it in GitHub Desktop.
Deploy from GitLab to WPEngine (Tested)
This file contains hidden or 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
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 |
The quick note:
You also need to add a private key to WPEngine to ensure the GitLab CI could be create a new commit or push to WPEngine.
Have a nice day!
@peterjudicialwatch thank you! Hope you enjoy it!
@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
- Push to dev branch (gitlab.com)
- Deploy to dev environment (wpengine)
Process STAGE
- Push to stage branch (gitlab.com)
- Deploy to stage environment (wpengine)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Khoipro It was a good start: