Search code examples
laravelcirclecicircleci-2.0circleci-workflows

CircleCI YAML config fails


I have created a CircleCI config which will run my PHPUnit tests against my laravel application and that is working 100% however I am now trying to add a workflow to then SSH and deploy my app to an AWS EC2 server and I am getting the following errors:

Your config file has errors and may not run correctly: 2 schema violations found required key [jobs] not found required key [version] not found

However I cannot see an issue with my CircleCI config file, have I made a mistake somewhere?

version: 2
jobs:
  build:
    docker:
      - image: circleci/php:7.1-browsers
    working_directory: ~/laravel
    steps:
      - checkout

      - run:
         name: Download NodeJS v6
         command: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

      - run:
         name: Install SQLite and NodeJS 6
         command: sudo apt-get install -y libsqlite3-dev nodejs

      - run:
         name: Setup Laravel testing environment variables for CircleCI test
         command: cp .env.circleci .env

      - run:
         name: Update composer to latest version
         command: composer self-update

      - restore_cache:
          keys:
            - composer-v1-{{ checksum "composer.json" }}
            - composer-v1-
      - run: composer install -n --prefer-dist --ignore-platform-reqs
      - save_cache:
          key: composer-v1-{{ checksum "composer.json" }}
          paths:
            - vendor

      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install NodeJS Packages
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules

      - run:
         name: Create SQLite Database
         command: touch database/database.sqlite

      - run:
         name: Migrate Laravel Database
         command: php artisan migrate --database=sqlite --force

      - run:
         name: Run NPM
         command: npm run production

      # Run Laravel Server for front-end tests
      - run:
         name: Run Laravel Server
         command: php artisan serve
         background: true

      - run:
         name: Run PHPUnit Tests
         command: vendor/bin/phpunit
 deploy:
    machine:
      enabled: true
    steps:
      - run:
          name: Deploy Over SSH
          command: |
            ssh $SSH_USER@$SSH_HOST "cd /var/www/html"

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

Any help is appreciated, thank you!


Solution

  • CircleCI has documentation for AWS deployment. Look here https://circleci.com/docs/1.0/continuous-deployment-with-aws-codedeploy/

    I think your problem is with SSH authorization for AWS. You can try it locally and make sure that your authorization is successfully, and then do the same thing with your AWS.