From 0e05b17920402c0c7257adc1f3497cdcc2804ca4 Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Thu, 17 Oct 2024 15:58:55 -0400 Subject: [PATCH 1/9] Push container images Signed-off-by: Mike McKiernan --- .github/workflows/docs-build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index 6c3cd00ba..2825f8b0d 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -14,7 +14,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - TAG: 0.2.0 + TAG: 0.3.0 GH_TOKEN: ${{ github.token }} concurrency: @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - packages: read + packages: write outputs: changed: ${{ steps.change.outputs.changed }} image: ${{ steps.change.outputs.image }} From 9f2a6431f2478151724dda0878dad340ccb7ff5a Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 09:39:23 -0400 Subject: [PATCH 2/9] Upload and download image Signed-off-by: Mike McKiernan --- .github/workflows/docs-build.yaml | 42 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index 2825f8b0d..b9eca09d1 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -2,11 +2,11 @@ name: docs-build on: pull_request: - branches: [ master, main ] + branches: [ main ] types: [ opened, synchronize ] push: - branches: [ master, main ] + branches: [ main ] tags: - v* workflow_dispatch: @@ -26,15 +26,13 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - packages: write + packages: read outputs: changed: ${{ steps.change.outputs.changed }} image: ${{ steps.change.outputs.image }} steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 2 - name: Log in to Container Registry uses: docker/login-action@v3 with: @@ -92,22 +90,42 @@ jobs: file: docker/Dockerfile push: true tags: ${{ needs.dockerfile-changed.outputs.image }} + if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch + - name: Build and save + uses: docker/build-push-action@v6 + with: + context: . + file: docker/Dockerfile + tags: ${{ needs.dockerfile-changed.outputs.image }} + outputs: type=oci,dest=/tmp/image.tar + if: github.event_name == 'pull_request' + - name: Upload image + uses: actions/upload-artifact@v4 + with: + name: image + path: /tmp/image.tar + if: github.event_name == 'pull_request' build-docs: needs: [dockerfile-changed, build-and-push-image] if: ${{ always() }} runs-on: ubuntu-latest - container: - image: ${{ needs.dockerfile-changed.outputs.image }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Set ownership + - name: Download image + uses: actions/download-artifact@v4 + with: + name: image + path: /tmp/ + if: github.event_name == 'pull_request' + - name: Load image run: | - chown -R $(id -u):$(id -g) $PWD + docker load --input /tmp/image.tar + if: github.event_name == 'pull_request' - name: Build docs run: | - ./repo docs + docker run -v $(pwd):/work -w /work ${{ needs.dockerfile-changed.outputs.image }} ./repo docs - name: Delete unnecessary files run: | find _build -name .doctrees -prune -exec rm -rf {} \; @@ -124,7 +142,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 +157,7 @@ jobs: store-html: needs: [ build-docs ] - if: ${{ github.event_name == 'push' }} + if: github.event_name == 'push' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 46c507065d2ce015c191edd44a3eb6acec835dc9 Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 09:45:47 -0400 Subject: [PATCH 3/9] Use Docker exporter Signed-off-by: Mike McKiernan --- .github/workflows/docs-build.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index b9eca09d1..55a2c908c 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -73,10 +73,8 @@ jobs: contents: read packages: write 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: @@ -97,7 +95,7 @@ jobs: context: . file: docker/Dockerfile tags: ${{ needs.dockerfile-changed.outputs.image }} - outputs: type=oci,dest=/tmp/image.tar + outputs: type=docker,dest=/tmp/image.tar if: github.event_name == 'pull_request' - name: Upload image uses: actions/upload-artifact@v4 From f081f9052f23254ad9dc161a1c844ae82f21c2e1 Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 09:50:14 -0400 Subject: [PATCH 4/9] Use local build output Signed-off-by: Mike McKiernan --- .github/workflows/docs-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index 55a2c908c..22e75eabb 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -95,7 +95,7 @@ jobs: context: . file: docker/Dockerfile tags: ${{ needs.dockerfile-changed.outputs.image }} - outputs: type=docker,dest=/tmp/image.tar + outputs: type=local,dest=/tmp/image.tar if: github.event_name == 'pull_request' - name: Upload image uses: actions/upload-artifact@v4 From f825a97495630e783c7dbe71b7174227ceeb42bc Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 09:54:45 -0400 Subject: [PATCH 5/9] Use checkout and buildx Signed-off-by: Mike McKiernan --- .github/workflows/docs-build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs-build.yaml b/.github/workflows/docs-build.yaml index 22e75eabb..5f5ce1229 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -73,6 +73,8 @@ jobs: contents: read packages: write steps: + - name: Checkout + uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Container Registry From 5c2e183b865674edee93a8ce7c50c214622bcd34 Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 10:29:01 -0400 Subject: [PATCH 6/9] Separate push and pull_request build paths Signed-off-by: Mike McKiernan --- .github/workflows/docs-build-pr.yaml | 46 ++++++++++++++++++++++++++ .github/workflows/docs-build.yaml | 34 ++----------------- .github/workflows/docs-preview-pr.yaml | 4 +-- 3 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/docs-build-pr.yaml diff --git a/.github/workflows/docs-build-pr.yaml b/.github/workflows/docs-build-pr.yaml new file mode 100644 index 000000000..90dd8f673 --- /dev/null +++ b/.github/workflows/docs-build-pr.yaml @@ -0,0 +1,46 @@ +name: docs-build + +on: + pull_request: + branches: [ main ] + types: [ opened, synchronize ] + +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: Build docs + run: | + ./repo docs + - name: Delete unnecessary files + run: | + find _build -name .doctrees -prune -exec rm -rf {} \; + find _build -name .buildinfo -exec rm {} \; + - name: Copy review page + run: | + mv _build/docs/review/latest/* _build/docs + 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 5f5ce1229..58df2f698 100644 --- a/.github/workflows/docs-build.yaml +++ b/.github/workflows/docs-build.yaml @@ -1,10 +1,6 @@ name: docs-build on: - pull_request: - branches: [ main ] - types: [ opened, synchronize ] - push: branches: [ main ] tags: @@ -90,42 +86,19 @@ jobs: file: docker/Dockerfile push: true tags: ${{ needs.dockerfile-changed.outputs.image }} - if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch - - name: Build and save - uses: docker/build-push-action@v6 - with: - context: . - file: docker/Dockerfile - tags: ${{ needs.dockerfile-changed.outputs.image }} - outputs: type=local,dest=/tmp/image.tar - if: github.event_name == 'pull_request' - - name: Upload image - uses: actions/upload-artifact@v4 - with: - name: image - path: /tmp/image.tar - if: github.event_name == 'pull_request' build-docs: needs: [dockerfile-changed, build-and-push-image] + container: + image: ${{ needs.dockerfile-changed.outputs.image }} if: ${{ always() }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Download image - uses: actions/download-artifact@v4 - with: - name: image - path: /tmp/ - if: github.event_name == 'pull_request' - - name: Load image - run: | - docker load --input /tmp/image.tar - if: github.event_name == 'pull_request' - name: Build docs run: | - docker run -v $(pwd):/work -w /work ${{ needs.dockerfile-changed.outputs.image }} ./repo docs + ./repo docs - name: Delete unnecessary files run: | find _build -name .doctrees -prune -exec rm -rf {} \; @@ -157,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 }} From db739a019104b4a4ea6cc3d36221dae76b39d600 Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 10:47:24 -0400 Subject: [PATCH 7/9] Build image for PRs Signed-off-by: Mike McKiernan --- .github/workflows/docs-build-pr.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-build-pr.yaml b/.github/workflows/docs-build-pr.yaml index 90dd8f673..8be1538ed 100644 --- a/.github/workflows/docs-build-pr.yaml +++ b/.github/workflows/docs-build-pr.yaml @@ -1,10 +1,13 @@ -name: docs-build +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 @@ -15,9 +18,18 @@ jobs: 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 + push: false + tags: pr-image:${{ github.sha }} - name: Build docs run: | - ./repo docs + docker run -v $(pwd):/work -w /work pr-image:${{ github.sha }} ./repo docs - name: Delete unnecessary files run: | find _build -name .doctrees -prune -exec rm -rf {} \; From d2d0825f8efe2538cf2ab0b265aa8cf94305169a Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 10:59:52 -0400 Subject: [PATCH 8/9] Load image into Docker for next step Signed-off-by: Mike McKiernan --- .github/workflows/docs-build-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs-build-pr.yaml b/.github/workflows/docs-build-pr.yaml index 8be1538ed..c97235649 100644 --- a/.github/workflows/docs-build-pr.yaml +++ b/.github/workflows/docs-build-pr.yaml @@ -25,7 +25,7 @@ jobs: with: context: . file: docker/Dockerfile - push: false + load: true tags: pr-image:${{ github.sha }} - name: Build docs run: | From b4405d32b73b01c416dfafb8afc761bd0fd6bc76 Mon Sep 17 00:00:00 2001 From: Mike McKiernan Date: Fri, 18 Oct 2024 11:08:53 -0400 Subject: [PATCH 9/9] Use sudo to delete unnecessary files in PRs Signed-off-by: Mike McKiernan --- .github/workflows/docs-build-pr.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs-build-pr.yaml b/.github/workflows/docs-build-pr.yaml index c97235649..4b694a9e8 100644 --- a/.github/workflows/docs-build-pr.yaml +++ b/.github/workflows/docs-build-pr.yaml @@ -32,12 +32,12 @@ jobs: docker run -v $(pwd):/work -w /work pr-image:${{ github.sha }} ./repo docs - name: Delete unnecessary files run: | - find _build -name .doctrees -prune -exec rm -rf {} \; - find _build -name .buildinfo -exec rm {} \; + sudo find _build -name .doctrees -prune -exec rm -rf {} \; + sudo find _build -name .buildinfo -exec rm {} \; - name: Copy review page run: | - mv _build/docs/review/latest/* _build/docs - rm -rf _build/docs/review _build/docs/tmp _build/docs/sphinx_warnings.txt + 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: