This workflow uses the on
block to specify that it should be triggered on
pushes to the staging
branch and pull requests to the master
branch.
The jobs
block defines a single job called build-and-deploy
. This job runs
on an Ubuntu 20.04 (Focal) environment and consists of seven steps:
- Checkout code
- Install Composer dependencies
- Run Laravel Artisan commands
- Install npm dependencies
- Run Vue.js build script (prod mode)
- Deploy to environment using the
appleboy/ssh-action
action - Set DEPLOY_TO_DOMAIN environment variable based on the branch being pushed or the pull request being merged.
The secrets
block defines four separate secrets for staging and production
environments:
DEPLOY_TO_STAGING_KEY
DEPLOY_TO_STAGING_HOST
DEPLOY_TO_STAGING_USERNAME
DEPLOY_TO_PRODUCTION_KEY
DEPLOY_TO_PRODUCTION_HOST
DEPLOY_TO_PRODUCTION_USERNAME
These secrets are used in the deployment script to determine which environment to deploy to based on the branch being pushed or the pull request being merged.