|
| 1 | +# Sample workflow for building and deploying a VitePress site to GitHub Pages |
| 2 | +name: Deploy VitePress site to gh-pages |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + pages: write |
| 13 | + id-token: write |
| 14 | + |
| 15 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 16 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 17 | +concurrency: |
| 18 | + group: pages |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + # Build job |
| 23 | + deploy-docs: |
| 24 | + runs-on: ubuntu-24.04 |
| 25 | + env: |
| 26 | + DOC_VERSION: v5 # The directory in gh-pages where the documentation would be deployed |
| 27 | + DOC_ALIAS: next # Change this to update the alias route. Note: Check the old alias when changing this! |
| 28 | + GIT_COMMITTER_NAME: "OpenUI5 Bot" |
| 29 | + GIT_COMMITTER_EMAIL: "[email protected]" |
| 30 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v5 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + - name: Setup Node |
| 37 | + uses: actions/setup-node@v6 |
| 38 | + with: |
| 39 | + node-version: 22.20.0 |
| 40 | + cache: npm |
| 41 | + - name: Setup Pages |
| 42 | + uses: actions/configure-pages@v4 |
| 43 | + - name: Install dependencies |
| 44 | + run: npm ci --engine-strict # --engine-strict is used to fail-fast if deps require node versions unsupported by the repo |
| 45 | + - name: Install documentation dependencies |
| 46 | + working-directory: packages/documentation |
| 47 | + run: npm ci --engine-strict # --engine-strict is used to fail-fast if deps require node versions unsupported by the repo |
| 48 | + - name: Fetch gh-pages branch |
| 49 | + run: git fetch origin gh-pages --depth=1 |
| 50 | + - name: generate CLI doc |
| 51 | + working-directory: packages/documentation |
| 52 | + run: npm run generate-cli-doc |
| 53 | + - name: Build vitepress build |
| 54 | + working-directory: packages/documentation |
| 55 | + run: | |
| 56 | + # The base output |
| 57 | + npm run build:vitepress -- --base="/${{ github.event.repository.name }}/${DOC_VERSION}/" |
| 58 | + npm run build:assets -- ./dist |
| 59 | + # The alias output |
| 60 | + npm run build:vitepress -- --base="/${{ github.event.repository.name }}/${DOC_ALIAS}/" --outDir="dist-${DOC_ALIAS}" |
| 61 | + npm run build:assets -- ./dist-${DOC_ALIAS} |
| 62 | + - name: Build jsdoc |
| 63 | + working-directory: packages/documentation |
| 64 | + run: npm run jsdoc-generate |
| 65 | + # TODO: Skip for now deployment of the schema until we do a Schema Version 5 release |
| 66 | + # - name: Build Schema |
| 67 | + # run: | |
| 68 | + # npm run schema-generate |
| 69 | + # npm run schema-workspace-generate |
| 70 | + - name: Checkout gh-pages |
| 71 | + uses: actions/checkout@v5 |
| 72 | + with: |
| 73 | + ref: gh-pages |
| 74 | + path: gh-pages |
| 75 | + - name: Copy the additional resources to gh-pages |
| 76 | + run: | |
| 77 | + # TODO: Skip for now deployment of the schema until we do a Schema Version 5 release |
| 78 | + # rm -rf ./gh-pages/schema |
| 79 | + # cp -R ./site/schema ./gh-pages/ |
| 80 | + rm -rf ./gh-pages/${DOC_VERSION} |
| 81 | + rm -rf ./gh-pages/${DOC_ALIAS} |
| 82 | +
|
| 83 | + # Main version route |
| 84 | + cp -R ./packages/documentation/dist ./gh-pages/${DOC_VERSION}/ |
| 85 | +
|
| 86 | + # Alias route. E.g., next, latest, stable, etc. |
| 87 | + # For vitepress must be a copy with different config, not a symlink |
| 88 | + cp -R ./packages/documentation/dist-${DOC_ALIAS} ./gh-pages/${DOC_ALIAS}/ |
| 89 | + # Symlink the api docs to avoid duplication |
| 90 | + ln -s ../${DOC_VERSION}/api ./gh-pages/${DOC_ALIAS}/api |
| 91 | +
|
| 92 | + # TODO: Enable when v5 release is done |
| 93 | + # cp ./packages/documentation/scripts/resources/custom404.html ./gh-pages/404.html |
| 94 | + - name: Publish Docs |
| 95 | + run: | |
| 96 | + cd ./gh-pages |
| 97 | + git config --local user.email $GIT_COMMITTER_EMAIL |
| 98 | + git config --local user.name $GIT_COMMITTER_NAME |
| 99 | + git add . |
| 100 | + git commit -m "Updating supplemental resources for ${DOC_VERSION} documentation deployment" |
| 101 | + git push |
0 commit comments