diff --git a/.github/workflows/docs-build-pr.yaml b/.github/workflows/docs-build-pr.yaml new file mode 100644 index 000000000..4b694a9e8 --- /dev/null +++ b/.github/workflows/docs-build-pr.yaml @@ -0,0 +1,58 @@ +name: docs-build-pr + +on: + pull_request: + branches: [ main ] + types: [ opened, synchronize ] + +env: + GH_TOKEN: ${{ github.token }} + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build image + uses: docker/build-push-action@v6 + with: + context: . + file: docker/Dockerfile + load: true + tags: pr-image:${{ github.sha }} + - name: Build docs + run: | + docker run -v $(pwd):/work -w /work pr-image:${{ github.sha }} ./repo docs + - name: Delete unnecessary files + run: | + sudo find _build -name .doctrees -prune -exec rm -rf {} \; + sudo find _build -name .buildinfo -exec rm {} \; + - name: Copy review page + run: | + sudo mv _build/docs/review/latest/* _build/docs + sudo rm -rf _build/docs/review _build/docs/tmp _build/docs/sphinx_warnings.txt + - name: Upload HTML + uses: actions/upload-artifact@v4 + with: + name: html-build-artifact + path: _build/docs + if-no-files-found: error + retention-days: 1 + - name: Store PR information + run: | + mkdir ./pr + echo ${{ github.event.number }} > ./pr/pr.txt + echo ${{ github.event.pull_request.merged }} > ./pr/merged.txt + echo ${{ github.event.action }} > ./pr/action.txt + - name: Upload PR information + uses: actions/upload-artifact@v4 + with: + name: pr + path: pr/ diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index 6c3cd00ba..58df2f698 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -1,12 +1,8 @@ name: docs-build on: - pull_request: - branches: [ master, main ] - types: [ opened, synchronize ] - push: - branches: [ master, main ] + branches: [ main ] tags: - v* workflow_dispatch: @@ -14,7 +10,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - TAG: 0.2.0 + TAG: 0.3.0 GH_TOKEN: ${{ github.token }} concurrency: @@ -33,8 +29,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 2 - name: Log in to Container Registry uses: docker/login-action@v3 with: @@ -77,8 +71,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to Container Registry uses: docker/login-action@v3 with: @@ -95,16 +89,13 @@ jobs: build-docs: needs: [dockerfile-changed, build-and-push-image] - if: ${{ always() }} - runs-on: ubuntu-latest container: image: ${{ needs.dockerfile-changed.outputs.image }} + if: ${{ always() }} + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Set ownership - run: | - chown -R $(id -u):$(id -g) $PWD - name: Build docs run: | ./repo docs @@ -124,7 +115,7 @@ jobs: if-no-files-found: error retention-days: 1 - name: Store PR information - if: ${{ github.event_name == 'pull_request' }} + if: github.event_name == 'pull_request' run: | mkdir ./pr echo ${{ github.event.number }} > ./pr/pr.txt @@ -139,7 +130,6 @@ jobs: store-html: needs: [ build-docs ] - if: ${{ github.event_name == 'push' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/docs-preview-pr.yaml b/.github/workflows/docs-preview-pr.yaml index 333a631ad..7a447c1e9 100644 --- a/.github/workflows/docs-preview-pr.yaml +++ b/.github/workflows/docs-preview-pr.yaml @@ -2,9 +2,9 @@ name: docs-preview-pr on: workflow_run: - workflows: [ docs-build ] + workflows: [ docs-build-pr ] types: [ completed ] - branches-ignore: [ 'master' ] + branches-ignore: [ main ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}