Skip to content

Instantly share code, notes, and snippets.

@camwhite
Last active March 19, 2020 08:50
Show Gist options
  • Select an option

  • Save camwhite/2a1343d5ee53d35f5c9dba8a2b5e0dc1 to your computer and use it in GitHub Desktop.

Select an option

Save camwhite/2a1343d5ee53d35f5c9dba8a2b5e0dc1 to your computer and use it in GitHub Desktop.

Revisions

  1. camwhite revised this gist Jun 22, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -29,4 +29,5 @@ deploy:
    # Non interactive ssh gracefully reloads server
    - ssh $SERVER_USER@$SERVER_IP '. /etc/profile; pm2 reload all'
    only:
    # Trigger deployments only from master branch
    - master
  2. camwhite revised this gist Jun 22, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ deploy:
    stage: deploy
    script:
    - rsync -avuz --exclude=".*" $CI_PROJECT_DIR $SERVER_USER@$SERVER_IP:~
    # Non interactive ssh gracefully reloads server
    - ssh $SERVER_USER@$SERVER_IP '. /etc/profile; pm2 reload all'
    only:
    - master
  3. camwhite revised this gist Jun 22, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -8,12 +8,15 @@ stages:
    - deploy

    before_script:
    # Check for ssh-agent + rsync and install if not present
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
    - eval $(ssh-agent -s)
    # Inject the remote's private key
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    # Append keyscan output into known hosts
    - ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - npm install
  4. camwhite created this gist Jun 22, 2018.
    28 changes: 28 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    image: node:8.9.0

    cache:
    paths:
    - node_modules/

    stages:
    - deploy

    before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - npm install
    - npm run build

    deploy:
    stage: deploy
    script:
    - rsync -avuz --exclude=".*" $CI_PROJECT_DIR $SERVER_USER@$SERVER_IP:~
    - ssh $SERVER_USER@$SERVER_IP '. /etc/profile; pm2 reload all'
    only:
    - master