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