deploy.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. name: Build and Deploy
  2. on:
  3. push:
  4. branches: [ "master"]
  5. pull_request:
  6. branches: [ "master" ]
  7. jobs:
  8. ensure-toolchain:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v3
  12. - name: Setup Node.js environment
  13. uses: actions/setup-node@v3.7.0
  14. with:
  15. node-version: "20.11.0"
  16. - name: Cache dependencies
  17. id: cache-node-modules
  18. uses: actions/cache@v3
  19. env:
  20. cache-name: cache-node-modules
  21. with:
  22. path: ./node_modules
  23. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package.json') }}
  24. - name: echo node version
  25. run: node -v
  26. - if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
  27. name: Install dependencies
  28. continue-on-error: true
  29. run: |
  30. sudo apt update && sudo apt install -y build-essential
  31. source ~/.bashrc
  32. npm install
  33. build-and-deploy:
  34. runs-on: ubuntu-latest
  35. needs: [ensure-toolchain]
  36. environment:
  37. name: github-pages
  38. steps:
  39. - uses: actions/checkout@v3
  40. - name: Cache dependencies
  41. id: cache-node-modules
  42. uses: actions/cache@v3
  43. env:
  44. cache-name: cache-node-modules
  45. with:
  46. path: ./node_modules
  47. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package.json') }}
  48. - name: Setup Node.js environment
  49. uses: actions/setup-node@v3.7.0
  50. with:
  51. node-version: "20.11.0"
  52. - name: Build
  53. run: npm run docs:build
  54. - name: Set CNAME
  55. run: echo 'community.dragonos.org' > ./.vuepress/dist/CNAME
  56. - name: Deploy
  57. uses: peaceiris/actions-gh-pages@v4
  58. with:
  59. github_token: ${{ secrets.GITHUB_TOKEN }}
  60. publish_dir: ./.vuepress/dist