Deploy Laravel for GitLab CI/CD
View on GitHub

Step 1: Add the deployment script to your project

Download and extract the deployment script. Add the .gitlab-ci.yml file and .gitlab/ directory to the root of your project.

This is how the deployment script is structured:

  • .gitlab-ci.yml
    • This file contains the GitLab CI/CD workflow. It tells GitLab what kind of runner we want and what it should do.
  • .gitlab/deployment/prepare.sh
    • This bash script prepares the runner to run the deployment. This script is executed inside the GitLab runner.
  • .gitlab/deployment/deploy.sh
    • This bash script is executed on the remote server. It performs the actual deployment.
  • .gitlab/deployment/hooks/
    • This directory contains hooks to customize your deployment. These hooks perform actions such as caching the config, flushing opcache, and restarting the queue.