From b3f907f3ec4c3daa2dc00aa49f62d69d06ed2632 Mon Sep 17 00:00:00 2001 From: Paul Gottschling Date: Wed, 23 Apr 2025 17:15:35 -0400 Subject: [PATCH] Configure required GHA jobs for merge_group We recently configured docs-website to use merge queues, and have one job with a `merge_group` trigger. Since the required checks do not have a `merge_group` trigger, though, merge queues time out waiting for checks to be reported. - Move the docs build check into Amplify Preview. A job called "Amplify Preview" is required to run. Move the "Check the docs build" step into the docs preview workflow. Run one of two "Amplify Preview" jobs depending on the event type. - Trigger all expected workflows on the `merge_group` event, but add an `if` condition so they pass if the event is merge_group. Do not add an `if` condition to the `Dependency Review` job, since it seems to conflict with the `uses` field. The job takes < 30s, so there is not much harm in running it on `merge_group`. --- .github/workflows/amplify-preview.yaml | 31 ++++++++++++++++++++++ .github/workflows/check-build.yaml | 33 ------------------------ .github/workflows/codeql.yml | 4 ++- .github/workflows/dependency-review.yaml | 1 + .github/workflows/test.yaml | 2 ++ 5 files changed, 37 insertions(+), 34 deletions(-) delete mode 100644 .github/workflows/check-build.yaml diff --git a/.github/workflows/amplify-preview.yaml b/.github/workflows/amplify-preview.yaml index b996024..b9a1f41 100644 --- a/.github/workflows/amplify-preview.yaml +++ b/.github/workflows/amplify-preview.yaml @@ -1,6 +1,7 @@ name: Docs Preview on: pull_request: + merge_group: permissions: pull-requests: write @@ -8,6 +9,7 @@ permissions: jobs: amplify-preview: + if: ${{ github.event_name != 'merge_group' }} name: Amplify Preview runs-on: ubuntu-22.04-2core-arm64 environment: docs-amplify @@ -25,3 +27,32 @@ jobs: create_branches: "false" github_token: ${{ secrets.GITHUB_TOKEN }} wait: "true" + + # If the event is merge_group, we want to make sure the build passes with the + # most recent version of the docs content to prevent unexpected inputs from + # breaking the build. Execute a local build on the GitHub Actions runner + # without a preview link. + local-preview: + if: ${{ github.event_name == 'merge_group'}} + name: Amplify Preview + runs-on: ubuntu-22.04-2core-arm64 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 23 + cache: 'yarn' + - name: Install deps + run: yarn + - name: Prepare docs site configuration + # Replace data fetched from Sanity CMS with hardcoded JSON objects to + # remove the need to authenticate with Sanity. Each includes the minimal + # set of data required for docs builds to succeed. + run: | + NEW_PACKAGE_JSON=$(jq '.scripts."prepare-sanity-data" = "echo Using pre-populated Sanity data"' package.json); + echo "$NEW_PACKAGE_JSON" > package.json; + echo "{}" > data/events.json + echo '{"bannerButtons":{"second":{"title":"LOG IN","url":"https://teleport.sh"},"first":{"title":"Support","url":"https://goteleport.com/support/"}},"navbarData":{"rightSide":{},"logo":"/favicon.svg","menu":[]}}' > data/navbar.json + + - name: Build the docs with the latest content + run: yarn build diff --git a/.github/workflows/check-build.yaml b/.github/workflows/check-build.yaml deleted file mode 100644 index 6ab9b60..0000000 --- a/.github/workflows/check-build.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# Check the docs build with the latest content in each gravitational/teleport -# submodule before merging docs-website changes. -name: Check the docs build -on: - merge_group: - pull_request: - paths: - - '.github/workflows/check-build.yaml' - -jobs: - check-build: - name: Check the docs build - runs-on: ubuntu-22.04-2core-arm64 - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 23 - cache: 'yarn' - - name: Install deps - run: yarn - - name: Prepare docs site configuration - # Replace data fetched from Sanity CMS with hardcoded JSON objects to - # remove the need to authenticate with Sanity. Each includes the minimal - # set of data required for docs builds to succeed. - run: | - NEW_PACKAGE_JSON=$(jq '.scripts."prepare-sanity-data" = "echo Using pre-populated Sanity data"' package.json); - echo "$NEW_PACKAGE_JSON" > package.json; - echo "{}" > data/events.json - echo '{"bannerButtons":{"second":{"title":"LOG IN","url":"https://teleport.sh"},"first":{"title":"Support","url":"https://goteleport.com/support/"}},"navbarData":{"rightSide":{},"logo":"/favicon.svg","menu":[]}}' > data/navbar.json - - - name: Build the docs with the latest content - run: yarn build diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ccf4911..c2649bb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,10 +9,12 @@ on: branches: - main - dev + merge_group: jobs: analyze: - name: Analyze + if: ${{ github.event_name != 'merge_group' }} + name: CodeQL runs-on: ubuntu-latest permissions: actions: read diff --git a/.github/workflows/dependency-review.yaml b/.github/workflows/dependency-review.yaml index 0bb522f..bf33ceb 100644 --- a/.github/workflows/dependency-review.yaml +++ b/.github/workflows/dependency-review.yaml @@ -2,6 +2,7 @@ name: Dependency Review on: pull_request: + merge_group: jobs: dependency-review: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a5f7881..a0bffc3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,10 +1,12 @@ name: Test on: pull_request: + merge_group: jobs: run-tests: name: Run tests + if: ${{ github.event_name != 'merge_group' }} runs-on: ubuntu-22.04-2core-arm64 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2