deploy.yml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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:
  34. runs-on: ubuntu-latest
  35. needs: [ensure-toolchain]
  36. steps:
  37. - uses: actions/checkout@v3
  38. - name: Cache dependencies
  39. id: cache-node-modules
  40. uses: actions/cache@v3
  41. env:
  42. cache-name: cache-node-modules
  43. with:
  44. path: ./node_modules
  45. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package.json') }}
  46. - name: Setup Node.js environment
  47. uses: actions/setup-node@v3.7.0
  48. with:
  49. node-version: "20.11.0"
  50. - name: echo node version
  51. run: node -v
  52. - name: Build
  53. run: npm run docs:build
  54. deploy:
  55. runs-on: ubuntu-latest
  56. needs: [ensure-toolchain]
  57. environment:
  58. name: github-pages
  59. steps:
  60. - name: Check github secrets
  61. run: sh -c 'if [ -z "${{ secrets.ACTIONS_DEPLOY_KEY }}" ]; then
  62. echo "GitHub Actions deploy key is missing";
  63. exit 1;
  64. fi'
  65. - uses: actions/checkout@v3
  66. - name: Cache dependencies
  67. id: cache-node-modules
  68. uses: actions/cache@v3
  69. env:
  70. cache-name: cache-node-modules
  71. with:
  72. path: ./node_modules
  73. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package.json') }}
  74. - name: Setup Node.js environment
  75. uses: actions/setup-node@v3.7.0
  76. with:
  77. node-version: "20.11.0"
  78. - name: Build
  79. run: npm run docs:build
  80. - name: Set CNAME
  81. run: echo 'community.dragonos.org' > ./.vuepress/dist/CNAME
  82. - name: Deploy
  83. uses: peaceiris/actions-gh-pages@v4
  84. with:
  85. github_token: ${{ secrets.GITHUB_TOKEN }}
  86. publish_dir: ./.vuepress/dist