Created
August 7, 2025 08:44
-
-
Save kidino/5215f1b29b7ab40f20530fdffaafde74 to your computer and use it in GitHub Desktop.
gitlab-ci.yml -- no delete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
- deploy | |
build_laravel: | |
stage: build | |
image: lorisleiva/laravel-docker:8.2 | |
only: | |
- master | |
script: | |
- set -e | |
- echo "Running composer install" | |
- composer install --no-dev --optimize-autoloader | |
- echo "Running npm install and build" | |
- npm install | |
- npm run build | |
artifacts: | |
paths: | |
- vendor/ | |
- public/build/ # adjust if your app uses a different folder for built assets | |
- bootstrap/cache/ | |
- .env.example # if you need this | |
- artisan | |
- composer.json | |
- composer.lock | |
- package.json | |
- package-lock.json | |
- resources/ # blade templates, etc. | |
- routes/ | |
- app/ | |
- config/ | |
- database/ | |
expire_in: 1 hour | |
deploy_laravel: | |
stage: deploy | |
image: lorisleiva/laravel-docker:8.2 | |
before_script: | |
- apk update && apk add sshpass openssh | |
only: | |
- master | |
dependencies: | |
- build_laravel | |
script: | |
- echo "Deploying to server via rsync (no --delete)" | |
- | | |
sshpass -p "$SSH_PASS" rsync -av \ | |
-e "ssh -o StrictHostKeyChecking=no" \ | |
--exclude 'storage/app/public' \ | |
--exclude 'public/storage' \ | |
./ "app-7@$SSH_HOST:/home/app-7/" | |
- echo "Running post-deploy artisan commands" | |
- | | |
sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no "app-7@$SSH_HOST" 'bash -s' <<EOSSH | |
set -e | |
cd /home/app-7 | |
mkdir -p storage/app/public | |
mkdir -p public/storage | |
[ -f "public/index.html" ] && rm public/index.html | |
php artisan config:cache | |
php artisan route:cache | |
php artisan view:cache | |
EOSSH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment