DEV Community

Cover image for Continuous Deploy in CircleCI to shared host ๐Ÿš€

Continuous Deploy in CircleCI to shared host ๐Ÿš€

CircleCI is a powerfull tool for continuous integration and continuous Deploy. Using docker to run builds in a clean and totaly customable container.
CircleCI integrates with GitHub and Bitbucket. Every time you commit code, CircleCI create a build.

If you interest in know more, please visit circleci.com.

So, in this post I show you how you can deploy to FTP using CircleCI.

After you create your account and link that with your Github or/and BitBucket, the steps is very simple, and I'm not abord this theme here.

CircleCI use yml file to configure how you integration is work's.
The file must be in the .circleci in your root project.

In this case, I'm use a php docker image with node. Then in command Im install git-ftp.
In the very first commit, you need pass git ftp init instad git ftp push, after that, you can change to git ftp push otherwise you receive an error.

Very first commit:

git ftp init --user "YOUR_FTP_USE" --passwd "YOUR_FTP_PASS" "ftp://youdomain.com/public_html/"
Enter fullscreen mode Exit fullscreen mode

Others commit:

git ftp push --user "YOUR_FTP_USE" --passwd "YOUR_FTP_PASS" "ftp://youdomain.com/public_html/"
Enter fullscreen mode Exit fullscreen mode

In deploy field you can set how branches you want deploy:

- deploy:
    filters:
      branches:
        only: master
Enter fullscreen mode Exit fullscreen mode

Complete yml file:

version: 2
jobs:
  deploy:
    docker:
      - image: circleci/php:7.1-node-browsers

    steps:
      - checkout

      - run: 
          name: Deploy Master Branch
          command: |
            sudo apt-get update
            sudo apt-get -qq install git-ftp
            echo "Deploying project ..."
            echo $(git status)
            echo "Deploying to my ftp"
            git ftp push --user "YOUR_FTP_USER" --passwd "YOUR_FTP_PASS" "ftp://youdomain.com/public_html/"

workflows:
  version: 2
  just-deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: master
Enter fullscreen mode Exit fullscreen mode

If you like this post, or need more information please comment bellow and I'm try to help you.

Top comments (0)