So I'm using a self-hosted GitLab instance trying to deploy my Laravel application. I am using the v10+ GitLab runner on a SSH executor.
Here is my .gitlab-ci.yml
:
stages:
- deploy
deploy_develop:
stage: deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- ssh-keyscan beta.beethovenworld.com > ~/.ssh/known_hosts
script:
- ssh -t nn2@beta.beethovenworld.com "chmod 400 ~/.ssh/id_rsa && cd /var/www/html && git pull origin develop -f && composer install --no-interaction --optimize-autoloader && php artisan key:generate && php artisan optimize && php artisan config:cache && php artisan route:cache && php artisan migrate"
environment:
name: beta
url: https://beta.beethovenworld.com
only:
- develop
As you can see, I am using SSH to go in and perform those actions. Let me know if there's a cleaner way to write this .yml
file.
The error:
From gitlab.beethovenworld.com:nn2/beethovenworld
* branch develop -> FETCH_HEAD
3c3ebf7..37f47cf develop -> origin/develop
error: Your local changes to the following files would be overwritten by merge:
resources/views/layouts/composer/manage.blade.php
Please, commit your changes or stash them before you can merge.
Aborting
Updating b4422e8..37f47cf
ERROR: Job failed: exit code 1
Why can I not do a git pull? I uploaded .git
folder to the server as well.
If I replace git pull origin develop
with git log
, the job is a success and I can see the latest git changes. Even now you can see the latest git commit. What am I doing wrong?