在 VPS 中使用 gitlab ci 部署 laravel 而无需 DOCKER

Deploy laravel using gitlab ci in VPS WITHOUT DOCKER

现在我有兴趣使用 gitlab ci cd 在我的自定义 VPS 上部署我的 laravel 应用程序,我想在没有 docker 的情况下进行。但是我找到的每个教程都使用 docker。我正在寻找一个 .gitlab.ci.yml 的样本来涵盖我的情况。 P.S。我已经为 laravel 配置了我的 vps。

经过对gitlab本身的一些研究和试验,我终于弄明白了。我使用了 gitlab-runner 来执行 .gitlab-ci.yml 中的作业,并在一开始就写了这个 yml 文件:

before_script:
  - echo "Before script"
  - cd /var/www/html/project
building:
  stage: build
  script:
    - git pull origin develop
    - composer install
    - cp .env.example .env
    - php artisan key:generate
    - php artisan migrate --seed
    - sudo chown -R my-user:www-data /var/www/html/project/
    - find /var/www/html/project -type f -exec chmod 664 {} \;
    - find /var/www/html/project -type d -exec chmod 775 {} \;
    - chgrp -R www-data storage bootstrap/cache
    - chmod -R ug+rwx storage bootstrap/cache
testing:
  stage: test
  script:
    - php ./vendor/bin/phpunit
deploying:
  stage: deploy
  script:
    - echo "Deployed"

如果你有更好的解决方案,可以写在这里