From a3ada255795d4e54f5b05bc5bb33aab1ac69c735 Mon Sep 17 00:00:00 2001 From: Jev Forsberg <46619047+baldm0mma@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:34:35 -0600 Subject: [PATCH] Chore: Migrate pr-docs pipeline to GHAs (#101982) * baldmomma/ add pr-lint-build-docs.yml * baldm0mma/ update codeowners * baldm0mma/ remove superfluous command * baldm0mma/ trigger * baldm0mma/ update with heredoc format * baldm0mma/ update content stash * baldm0mma/ explore container for prod target * baldm0mma/ update to use hugo directly * baldm0mma/ clone the websote dir * baldm0mma/ rebuild with docker * baldm0mma/ docker run * baldm0mma/ remove build trigger * baldm0mma/ remove cue gen step that is covered elsewhere --- .github/CODEOWNERS | 1 + .github/workflows/pr-lint-build-docs.yml | 52 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/pr-lint-build-docs.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 878975846db..fcb251d3f83 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -791,6 +791,7 @@ embed.go @grafana/grafana-as-code /.github/workflows/pr-codeql-analysis-javascript.yml @DanCech /.github/workflows/pr-codeql-analysis-python.yml @DanCech /.github/workflows/pr-commands.yml @tolzhabayev +/.github/workflows/pr-lint-build-docs.yml @grafana/docs-tooling /.github/workflows/pr-patch-check.yml @grafana/grafana-developer-enablement-squad /.github/workflows/pr-test-integration.yml @grafana/grafana-backend-group /.github/workflows/pr-backend-unit-tests.yml @grafana/grafana-backend-group diff --git a/.github/workflows/pr-lint-build-docs.yml b/.github/workflows/pr-lint-build-docs.yml new file mode 100644 index 00000000000..8ed36d3da9a --- /dev/null +++ b/.github/workflows/pr-lint-build-docs.yml @@ -0,0 +1,52 @@ +name: Documentation + +on: + pull_request: + paths: + - '*.md' + - 'docs/**' + - 'packages/**/*.md' + - 'latest.json' + +jobs: + docs: + name: Build & Verify Docs + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.11.0' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint docs + run: yarn run prettier:checkDocs + env: + # Increase memory for prettier due to large number of files + NODE_OPTIONS: --max_old_space_size=8192 + + - name: Build docs website + run: | + # Create and start a container from the docs-base image in detached mode + docker run -d --name docs-builder grafana/docs-base:latest tail -f /dev/null + + # Create the directory structure inside the container + docker exec docs-builder mkdir -p /hugo/content/docs/grafana/latest + + # Create the _index.md file + docker exec docs-builder /bin/sh -c "echo -e '---\nredirectURL: /docs/grafana/latest/\ntype: redirect\nversioned: true\n---\n' > /hugo/content/docs/grafana/_index.md" + + # Copy the docs sources from the host to the container + docker cp docs/sources/. docs-builder:/hugo/content/docs/grafana/latest/ + + # Run the make prod command inside the container + docker exec -w /hugo docs-builder make prod || echo "Build completed with warnings" + + # Clean up the container + docker rm -f docs-builder