Modern php application with automatically deploy via ssh by GitHub Actions
- Fork this project and clone it
cp -r laravel-template YOUR_NAME && cd YOUR_NAME/ && rm -rf .git
- Use
make up
for run docker containers - Run
make bash
for open docker container with application - Run
composer update
- Create new repo on GitHub, run
git init
, add remote, push it to GitHub - Generate new SSH key for access to server
- If this is the README of your fork, click this link to go to the "Secrets" page.
- Create new secret hash for waiting finish of current deploy process, create .env and update DEV_HASH (using by app/Http/Middleware/Development.php)
- Add new secrets:
- DEPLOY_URL: url of your website
- DEV_HASH: secret dev hash for access to deploy route
- DEPLOY_HOST: server's IP for SSH connection
- DEPLOY_PATH: path to website on server,
/var/www/html/something
- DEPLOY_PORT: server's port for SSH connection
- DEPLOY_USER: server's username for SSH connection
- DEPLOY_KEY_PASS: server's SSH public key passphrase
- Push new code to main branch and check GitHub Actions status
Main idea is to create basic deploy (via rsync) to remote server over SSH with waiting finish of current deploy process. GitHub Action is very simple, you can check .github/workflows/dev.yml. Step 'Check previous deploy' call specific url /deploy, which has response status. If we have deploy process, script waiting finish of process. For deploy we use burnett01/rsync-deployments@5.2, which use rsync for pushing files to remote server, where supervisor has cron tak This cron task run every 60 sec and apply migrations, remove deploy pid file, etc.
The Laravel framework is open-sourced software licensed under the MIT license.