vue_deploy.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: Vue Project Deploy With Docker Image
  2. on:
  3. push:
  4. branches: [ master ]
  5. paths-ignore:
  6. - '**/README.md'
  7. - '**/*.yml'
  8. tags: [release-v*]
  9. pull_request:
  10. branches: [master]
  11. jobs:
  12. build_vue:
  13. runs-on: ubuntu-latest
  14. defaults:
  15. run:
  16. working-directory: front
  17. strategy:
  18. matrix:
  19. node-version: [12.x]
  20. steps:
  21. - uses: actions/checkout@v2
  22. - name: User Node.js ${{natrix.node-version}}
  23. users: actions/setup=node@v1
  24. with:
  25. node-version: ${{matrix.node-version}}
  26. - name: npm Build
  27. run: |
  28. npm install
  29. npn run build
  30. - uses: actions/upload-artifact@v2
  31. with:
  32. name: distfile
  33. path: front/dist
  34. docker_image:
  35. needs: [build_vue]
  36. runs-on: ubuntu-latest
  37. steps:
  38. - uses: actions/checkout@v2
  39. - uses: actions/download-artifact@v2
  40. with:
  41. name: distfile
  42. path: wwwroot
  43. - name: Push to Docker Hub
  44. uses: docker/build-push-acation@v1
  45. with:
  46. username: ${{secrets.DOCKER_HUB_NAME}}
  47. password: ${{secrets.DOCKER_HUB_PASSWORD}}
  48. repository: jianboy/vue_demo
  49. tags: test
  50. # 构建镜像,推送镜像到仓库,并创建tag,部署
  51. deploy:
  52. needs: [docker_image]
  53. runs-on: ubuntu-latest
  54. steps:
  55. - uses: actions/checkout@v2
  56. - run: |
  57. docker login -u ${{secrets.DOCKER_HUB_NAME}} -p ${{secrets.DOCKER_HUB_PASSWORD}}
  58. docker-compose -f docker-compose.yml up -d
  59. # 登录远程服务器,拉取代码,部署
  60. deploy2:
  61. runs-on: ubuntu-latest
  62. steps:
  63. - run: |
  64. ssh -p 2222 jianboy@xx.com
  65. cd ~/xx/xx/xx/
  66. git fetch origin master
  67. git reset --hard origin/master
  68. docker-compose -f docker-compose.yml up -d