You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. name: devops
  2. on:
  3. push:
  4. tags:
  5. - v*
  6. workflow_dispatch:
  7. jobs:
  8. build:
  9. name: Build
  10. runs-on: ubuntu-latest
  11. strategy:
  12. matrix:
  13. node-version: ['16.x']
  14. go-version: ['1.16']
  15. steps:
  16. - name: Check out branch
  17. uses: actions/checkout@v2
  18. - name: Sed Config
  19. shell: bash
  20. run: |
  21. git branch
  22. ls -l
  23. - name: Use Node.js ${{ matrix.node-version }}
  24. uses: actions/setup-node@v2.1.2
  25. with:
  26. node-version: ${{ matrix.node-version }}
  27. - name: Build-Node
  28. run: |
  29. cd web/ && yarn install && yarn run build
  30. - name: Use Go ${{ matrix.go-version }}
  31. uses: actions/setup-go@v1
  32. with:
  33. go-version: ${{ matrix.go-version }}
  34. - name: Build-go
  35. run: |
  36. cd server/ && go mod tidy && go build && mkdir ../web/ser && mv server ../web/ser/ && cd ../web/ser/ && ls -s
  37. - name: restart
  38. env:
  39. KEY: ${{ secrets.KEY }}
  40. HOST: ${{ secrets.HOST }}
  41. USER: ${{ secrets.USER }}
  42. PROT: ${{ secrets.PROT }}
  43. MKDIR: ${{ secrets.MKDIR }}
  44. run: |
  45. mkdir -p ~/.ssh/ && echo "$KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
  46. ssh-keyscan github.com >> ~/.ssh/known_hosts
  47. scp -P ${PROT} -o StrictHostKeyChecking=no -r web/dist/* ${USER}@${HOST}:${MKDIR}dist/
  48. scp -P ${PROT} -o StrictHostKeyChecking=no -r web/ser/* ${USER}@${HOST}:${MKDIR}
  49. ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIR}resource/ && rm -rf ${MKDIR}resource/*"
  50. scp -P ${PROT} -o StrictHostKeyChecking=no -r server/resource/* ${USER}@${HOST}:${MKDIR}resource/
  51. ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIR} && bash restart.sh > /dev/null 2>&1 &"