docs.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. name: Documents
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches: [ "main" ]
  6. pull_request:
  7. branches: [ "main" ]
  8. jobs:
  9. ensure-toolchain:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v3
  13. - name: Setup Node.js environment
  14. uses: actions/[email protected]
  15. with:
  16. node-version: "20.11.0"
  17. - name: Cache dependencies
  18. id: cache-node-modules
  19. uses: actions/cache@v3
  20. env:
  21. cache-name: cache-node-modules
  22. with:
  23. path: ./docs/node_modules
  24. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('docs/package.json') }}-${{ hashFiles('docs/package-lock.json') }}
  25. - name: echo node version
  26. working-directory: ./docs
  27. run: node -v
  28. - if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
  29. name: Install dependencies
  30. working-directory: ./docs
  31. continue-on-error: true
  32. run: |
  33. sudo apt update && sudo apt install -y build-essential
  34. source ~/.bashrc
  35. npm install
  36. build-and-deploy:
  37. permissions:
  38. contents: write
  39. runs-on: ubuntu-latest
  40. needs: [ ensure-toolchain ]
  41. steps:
  42. - uses: actions/checkout@v3
  43. - name: Cache dependencies
  44. id: cache-node-modules
  45. uses: actions/cache@v3
  46. env:
  47. cache-name: cache-node-modules
  48. with:
  49. path: ./docs/node_modules
  50. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package.json') }}
  51. - name: Setup Node.js environment
  52. uses: actions/[email protected]
  53. with:
  54. node-version: "20.11.0"
  55. - name: Build
  56. working-directory: ./docs
  57. run: npm run docs:build
  58. - name: Deploy
  59. working-directory: ./docs
  60. env:
  61. AWS_ENDPOINT_URL: ${{ secrets.DOCS_DEPLOY_S3_ENDPOINT_URL }}
  62. AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_S3_API_KEY }}
  63. AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_S3_SECRET_KEY }}
  64. if: github.ref == 'refs/heads/main' && github.repository == 'DragonOS-Community/DADK'
  65. run: |
  66. sudo apt-get update
  67. sudo apt-get install -y python3-pip python3-setuptools
  68. python3 -m pip install --user awscli
  69. aws s3 sync ./.vuepress/dist s3://dragonos-docs/p/dadk --delete