deploy.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/[email protected]
  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. permissions:
  35. contents: write
  36. runs-on: ubuntu-latest
  37. needs: [ensure-toolchain]
  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/[email protected]
  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. if: github.ref == 'refs/heads/master'
  59. with:
  60. github_token: ${{ secrets.GITHUB_TOKEN }}
  61. publish_dir: ./.vuepress/dist