| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # Builds the website and runs tests using Docker. |
| # The Docker image contains only pnpm prod dependencies, so it is cached. |
| # The website build is stored as an artifact. |
| |
| name: docusaurus |
| |
| on: |
| workflow_call: |
| |
| concurrency: |
| group: docusaurus-${{ github.event.pull_request.number || github.sha }} |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| |
| env: |
| script_dir: .github/scripts |
| image_tar: ozone-site-image.tar |
| |
| jobs: |
| build-image: |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout project |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| persist-credentials: false |
| - name: Check Docker image cache |
| id: cache |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| with: |
| path: ${{ env.image_tar }} |
| key: image2-${{ hashFiles('Dockerfile', 'compose.yml', 'pnpm-lock.yaml') }} |
| lookup-only: true |
| - name: Build Docker image |
| if: steps.cache.outputs.cache-hit != 'true' |
| run: | |
| docker compose build |
| - name: Save docker image to tar |
| if: steps.cache.outputs.cache-hit != 'true' |
| run: | |
| docker save ozone-site --output="$image_tar" |
| - name: Save docker image tar to cache |
| if: steps.cache.outputs.cache-hit != 'true' |
| uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| with: |
| path: ${{ env.image_tar }} |
| key: image2-${{ hashFiles('Dockerfile', 'compose.yml', 'pnpm-lock.yaml') }} |
| build-website: |
| needs: |
| - build-image |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout project |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| persist-credentials: false |
| - name: Restore docker image tar from cache |
| uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| with: |
| path: ${{ env.image_tar }} |
| key: image2-${{ hashFiles('Dockerfile', 'compose.yml', 'pnpm-lock.yaml') }} |
| - name: Load docker image |
| run: | |
| docker load --input="$image_tar" |
| - name: Build website |
| run: | |
| docker compose run site pnpm build |
| - name: Save website build artifact |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| with: |
| name: build |
| path: build |
| include-hidden-files: true |
| if-no-files-found: error |
| retention-days: 1 |
| run-website: |
| needs: |
| - build-website |
| runs-on: ubuntu-latest |
| steps: |
| - name: Get Docker files |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| persist-credentials: false |
| - name: Download website build artifact |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| with: |
| name: build |
| path: build |
| - name: Restore docker image tar from cache |
| uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| with: |
| path: ${{ env.image_tar }} |
| key: image2-${{ hashFiles('Dockerfile', 'compose.yml', 'pnpm-lock.yaml') }} |
| - name: Load docker image |
| run: | |
| docker load --input="$image_tar" |
| - name: Curl website homepage |
| timeout-minutes: 5 |
| working-directory: ${{ env.script_dir }} |
| run: | |
| ./curl.sh |