我正在使用 laravel-deployer 包在我的服务器上部署我的项目。我有以下gitlab-ci
文件:
stages:
- build
- test
- deploy
image: lorisleiva/laravel-docker:7.4
.init_ssh: &init_ssh |
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan yourdomain.com >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
.change_file_permissions: &change_file_permissions |
find . -type f -not -path "./vendor/*" -exec chmod 664 {} \;
find . -type d -not -path "./vendor/*" -exec chmod 775 {} \;
composer:
stage: build
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress
- cp .env.production .env
- php artisan key:generate
artifacts:
expire_in: 1 month
paths:
- vendor/
- .env
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor/
npm:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}-npm
paths:
- node_modules/
script:
- npm install
- npm run production
artifacts:
expire_in: 1 month
paths:
- node_modules/
- public/css/
- public/js/
production:
stage: deploy
script:
- *init_ssh
- *change_file_permissions
- cp .env.production .env
- pwd
- hostname
- php artisan deploy yourdomain.com -s upload
- cd /var/www/yourdomain.com/current
- cp /var/www/yourdomain.com/current/.env.production /var/www/yourdomain.com/shared/.env
- npm install
- npm run production
environment:
name: production
url: http://yourdomain.com
when: manual
only:
- master
它基本上部署 laravel 网站,删除以前的版本,复制新版本并更改其权限,以便 Nginx 可读。所有步骤均已正确执行,但在完成并出现以下错误后总是失败:
✔
➤ Executing task artisan:migrate
✔
➤ Executing task deploy:symlink
✔
➤ Executing task deploy:unlock
✔
➤ Executing task cleanup
✔
➤ Executing task fpm:reload
✔
Successfully deployed in 16.63s
$ cd /var/www/yourdomain.com/current
/bin/bash: line 127: cd: /var/www/yourdomain.com/current: No such file or directory
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
即使管道正常工作,我也无法获得通过报告徽章,这让我很烦恼。