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