# Deployment

Production deployment is triggered by pushing the `release` branch to the bare repository.

The server hook at `/root/Parts.git/hooks/post-receive` should be installed from the versioned bootstrap script:

```bash
install -m 755 scripts/deploy/post-receive /root/Parts.git/hooks/post-receive
```

The bootstrap checks out `release` into `/srv/www/htdocs/Parts` and then runs the versioned deploy script from the checked-out release:

```text
scripts/deploy/release-post-checkout
```

This keeps the deployment steps in Git history. Future changes to `scripts/deploy/release-post-checkout` are picked up by the next release deployment after checkout. If `scripts/deploy/post-receive` itself changes, reinstall the server hook with the `install` command above.

The deploy script performs these steps:

```text
composer install --no-dev --optimize-autoloader --no-interaction --prefer-dist --no-progress --no-scripts
php artisan package:discover --ansi
npm ci --no-audit --no-fund
npm run build
php artisan migrate --force
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan queue:restart
chown -R wwwrun:www storage bootstrap/cache public/build
```

To validate the installed hook against the current release ref without creating a new commit:

```bash
rev=$(git --git-dir=/root/Parts.git rev-parse refs/heads/release)
printf "%s %s refs/heads/release\n" "$rev" "$rev" | /root/Parts.git/hooks/post-receive
```
