Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

faisalfaiz64's avatar

gitlab CI/CD deploy laravel project

I Want to deploy my laravel project through ci/cd gitlab, I have a problem with deploying my project. i am trying to deploy my laravel project to cpanel through gitlab CI. I am using deployer package in this project but when i push my commit to gitlab and pipeline got failed.

I got this error when I push my commit to gitlab and got this error in my pipeline error image

here is my deploy.php code

<?php
declare(strict_types=1);
return [
    'default' => 'basic',
    'strategies' => [
    ],
    'hooks' => [
        'start' => [
        ],
        'build' => [
        ],
        'ready' => [
            'artisan:storage:link',
            'artisan:view:clear',
            'artisan:config:cache',
            'artisan:migrate',
            'artisan:horizon:terminate',
        ],
        'done' => [
            'fpm:reload',
        ],
        'success' => [
        ],
        'fail' => [
        ],
        'rollback' => [
            'fpm:reload',
        ],
    ],
    'options' => [
        'application' => env('APP_NAME', 'Laravel'),
        'repository' => '[email protected]/mygroup/project.git',
        'php_fpm_service' => 'php7.4-fpm',
    ],

    'hosts' => [
        'mywebsite.com' => [
            'deploy_path' => '/home/sfd/public_html/nas',
            'user' => 'deployer',
        ],
    ],

    'localhost' => [

    ],


    'include' => [

    ],

    'custom_deployer_file' => false,

];

this is my gitlab-ci.yml code

image: edbizarro/gitlab-ci-pipeline-php:7.4

stages:
  - preparation
  - deploy

composer:
  stage: preparation
  script:
    - php -v
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts --no-suggest
    - cp .env.example .env
    - php artisan key:generate
  artifacts:
    paths:
      - vendor/
      - .env
    expire_in: 1 days
    when: always
  cache:
    paths:
      - vendor/
.init_ssh_live: &init_ssh_live |
  mkdir -p ~/.ssh
  echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
  chmod 600 ~/.ssh/id_rsa
  [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config



deploy:
  stage: deploy
  script:
    - *init_ssh_live
    - php artisan deploy my-website.com -s upload
  environment:
    name: live
    url: https://my-website.com
  only:
    - dev
0 likes
2 replies

Please or to participate in this conversation.