12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- name: Vue Project Deploy With Docker Image
- on:
- push:
- branches: [ master ]
- paths-ignore:
- - '**/README.md'
- - '**/*.yml'
- tags: [release-v*]
- pull_request:
- branches: [master]
- jobs:
- build_vue:
- runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: front
- strategy:
- matrix:
- node-version: [12.x]
-
- steps:
- - uses: actions/checkout@v2
- - name: User Node.js ${{natrix.node-version}}
- users: actions/setup=node@v1
- with:
- node-version: ${{matrix.node-version}}
-
- - name: npm Build
- run: |
- npm install
- npn run build
-
- - uses: actions/upload-artifact@v2
- with:
- name: distfile
- path: front/dist
- docker_image:
- needs: [build_vue]
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions/download-artifact@v2
- with:
- name: distfile
- path: wwwroot
- - name: Push to Docker Hub
- uses: docker/build-push-acation@v1
- with:
- username: ${{secrets.DOCKER_HUB_NAME}}
- password: ${{secrets.DOCKER_HUB_PASSWORD}}
- repository: jianboy/vue_demo
- tags: test
- # 构建镜像,推送镜像到仓库,并创建tag,部署
- deploy:
- needs: [docker_image]
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - run: |
- docker login -u ${{secrets.DOCKER_HUB_NAME}} -p ${{secrets.DOCKER_HUB_PASSWORD}}
- docker-compose -f docker-compose.yml up -d
- # 登录远程服务器,拉取代码,部署
- deploy2:
- runs-on: ubuntu-latest
- steps:
- - run: |
- ssh -p 2222 jianboy@xx.com
- cd ~/xx/xx/xx/
- git fetch origin master
- git reset --hard origin/master
- docker-compose -f docker-compose.yml up -d
-
|