部署

deploy.yml

  1. name: Deploy
  2. on:
  3. push:
  4. branches: [ master ]
  5. pull_request:
  6. branches: [ master ]
  7. jobs:
  8. laravel-deploy:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: executing remote ssh commands using ssh key
  12. uses: appleboy/ssh-action@master
  13. with:
  14. host: ${{ secrets.HOST }}
  15. username: ${{ secrets.USERNAME }}
  16. key: ${{ secrets.KEY }}
  17. port: ${{ secrets.PORT }}
  18. script: |
  19. cd /www/wwwroot/admin.ysbjlzlx.com
  20. git reset --hard origin/master
  21. git clean -df
  22. git pull 2>&1
  23. sh build.sh

build.sh

  1. #!/usr/bin/env bash
  2. export APP_ENV=production
  3. ### PHP
  4. composer check-platform-reqs --no-dev --no-interaction
  5. # 自动加载器优化
  6. composer install --optimize-autoloader --no-dev --no-interaction
  7. # 优化配置加载
  8. php artisan config:cache
  9. # 优化路由加载
  10. php artisan route:cache
  11. # 优化视图加载
  12. php artisan view:cache
  13. ### Node.js
  14. npm install
  15. # 运行所有的 Mix 任务并最小化输出
  16. npm run production
  17. ### 清理文件
  18. rm -rf node_modules
  19. ### 修复目录归属
  20. chown -R www:www .