Skip to content

Instantly share code, notes, and snippets.

@SippieCup
Created March 26, 2018 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SippieCup/26c891988098220bf408d2ffb6d1085b to your computer and use it in GitHub Desktop.
Save SippieCup/26c891988098220bf408d2ffb6d1085b to your computer and use it in GitHub Desktop.
Gitlab deploy to ionic cloud
deploy-app:
type: deploy
environment: ionic-deployment
only:
- development
- master
- production
when: manual
script:
##
## Look for SSH agent (install if unavailable)
##
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## SSH_PRIVATE_KEY is the private key that is attached to ionic cloud and
## saved in Settings -> CI / CD -> Secret Variables
##
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
##
## Disable strict host key checks for SSH connections (resolves host key rejection from
## the ionic git server not in .ssh/known_hosts)
##
- echo "StrictHostKeyChecking no" >> ~/.ssh/config
##
## Configure the git user for the Ionic cloud git repo
##
- git config --global user.email "user@email.com"
- git config --global user.name "Seymour Butz"
##
## Rebuild the git repo on the application subdirectory
##
- git filter-branch --prune-empty --subdirectory-filter application master
##
## Change Remote location to point to the Ionic cloud repo
##
- git remote remove origin
- git remote add origin git@git.ionicjs.com:repository/application.git
##
## Commit changes to repository and force push to master
##
- git push --set-upstream origin master -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment