Github Actions to test Laravel application (unit, feature & dusk tests) on MySql 8, deploy application connecting via ssh and run deployment script inside your server.
- Create the directory
./github/workflows
at the root of the project. - Add the
test_main.yml
file inside the./github/workflows
. - Add the
.env.ci
file at the root of the project. - Now any pull request on the main branch that affects code within the paths configured in the pipeline will execute the pipeline (feel free to modify the pipeline as best suits your workflow).
- Add the
deploy_prod.yml
file inside the./github/workflows
. - Add the
deploy.sh
file at the root of the project. - Modify all the lines
/var/www/project
inside thedeploy.sh
anddeploy_prod.yml
files with the name of your directory. - Add the following secrets inside repository settings (repository settings -> secrets -> actions):
HOST
(your server),PRIVATE_SSH_KEY
(your private ssh key, you must have previously added your public key to the server at~/ .ssh/authorized_keys
to allow you to connect to the server),USER
(user that will be used to try to connect to the server). - Now any push on the main branch will execute the deployment on your server, once it successfully connects to your server it will execute the deploy.sh script located at the root of the project (feel free to modify the pipeline and script as best suits your workflow).