From 2d8a5f94baa48be310aecb357d8b7b794d0e1237 Mon Sep 17 00:00:00 2001 From: Eva Sarafianou Date: Tue, 14 Jul 2026 14:29:28 +0300 Subject: [PATCH] Stop posting docs preview PR comments; link preview from status check (#37491) Docs preview cleanup and build workflows no longer post PR comments. The build workflows now surface the preview URL via the commit status's target_url instead, so the status check links directly to the preview. Co-authored-by: Cursor --- .github/workflows/docs-preview-cleanup.yml | 12 ----- .github/workflows/docs-preview-fork.yml | 3 +- .github/workflows/docs-preview-template.yml | 19 -------- .github/workflows/docs-preview.yml | 53 ++++++++++++++++++++- 4 files changed, 52 insertions(+), 35 deletions(-) diff --git a/.github/workflows/docs-preview-cleanup.yml b/.github/workflows/docs-preview-cleanup.yml index 2650cd8b3c8..6dcc9ef1caa 100644 --- a/.github/workflows/docs-preview-cleanup.yml +++ b/.github/workflows/docs-preview-cleanup.yml @@ -9,15 +9,11 @@ on: permissions: contents: read - pull-requests: write jobs: cleanup: name: Delete preview from S3 runs-on: ubuntu-latest - # Fork PRs don't get secrets on plain pull_request events, so this would - # just fail for them -- a separate scheduled sweep handles fork preview - # cleanup instead of switching this to pull_request_target. if: github.event.pull_request.head.repo.full_name == github.repository steps: - name: Configure AWS credentials @@ -33,11 +29,3 @@ jobs: BUCKET_NAME: ${{ vars.DOCS_PREVIEW_BUCKET_NAME }} run: | aws s3 rm "s3://${BUCKET_NAME}/mattermost/pr-${PR_NUMBER}/" --recursive - - - name: Comment on closed PR - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.number }} - run: | - gh pr comment "$PR_NUMBER" --repo "${{ github.repository }}" \ - --body "Docs preview for PR #${PR_NUMBER} has been removed from S3." diff --git a/.github/workflows/docs-preview-fork.yml b/.github/workflows/docs-preview-fork.yml index c800bee2193..fe25d6652ba 100644 --- a/.github/workflows/docs-preview-fork.yml +++ b/.github/workflows/docs-preview-fork.yml @@ -19,7 +19,6 @@ on: permissions: contents: read statuses: write - pull-requests: write jobs: update-initial-status: @@ -45,7 +44,6 @@ jobs: - update-initial-status with: PR_NUMBER: ${{ inputs.PR_NUMBER }} - TRIGGERING_ACTOR: ${{ inputs.TRIGGERING_ACTOR }} COMMIT_SHA: ${{ inputs.COMMIT_SHA }} update-failure-status: @@ -79,3 +77,4 @@ jobs: context: "docs-preview-fork / preview" description: "Docs preview build for ${{ inputs.COMMIT_SHA }} succeeded" status: success + target_url: "http://${{ vars.DOCS_PREVIEW_BUCKET_NAME }}.s3-website-us-east-1.amazonaws.com/mattermost/pr-${{ inputs.PR_NUMBER }}/" diff --git a/.github/workflows/docs-preview-template.yml b/.github/workflows/docs-preview-template.yml index 2c3ae4e0cd2..5efcd28d72e 100644 --- a/.github/workflows/docs-preview-template.yml +++ b/.github/workflows/docs-preview-template.yml @@ -6,9 +6,6 @@ on: PR_NUMBER: type: string required: true - TRIGGERING_ACTOR: - type: string - required: true COMMIT_SHA: type: string required: true @@ -26,7 +23,6 @@ concurrency: permissions: contents: read - pull-requests: write jobs: preview: @@ -93,18 +89,3 @@ jobs: "s3://${BUCKET_NAME}/mattermost/pr-${PR_NUMBER}/" \ --delete \ --no-progress - - - name: Post preview URL comment - # Plain gh CLI instead of a third-party action -- posts a new comment - # every run (same behavior peter-evans/create-or-update-comment had - # here, since it wasn't given a comment-id/body-includes matcher). - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ inputs.PR_NUMBER }} - TRIGGERING_ACTOR: ${{ inputs.TRIGGERING_ACTOR }} - COMMIT_SHA: ${{ inputs.COMMIT_SHA }} - BUCKET_NAME: ${{ vars.DOCS_PREVIEW_BUCKET_NAME }} - run: | - BODY=$(printf 'Newest code from %s and commit %s has docs preview environment ready:\n\n**[Open preview environment](http://%s.s3-website-us-east-1.amazonaws.com/mattermost/pr-%s/)**' \ - "$TRIGGERING_ACTOR" "$COMMIT_SHA" "$BUCKET_NAME" "$PR_NUMBER") - gh pr comment "$PR_NUMBER" --repo "${{ github.repository }}" --body "$BODY" diff --git a/.github/workflows/docs-preview.yml b/.github/workflows/docs-preview.yml index cdff5dc543a..c9697ac4db9 100644 --- a/.github/workflows/docs-preview.yml +++ b/.github/workflows/docs-preview.yml @@ -9,16 +9,65 @@ on: permissions: contents: read - pull-requests: write + statuses: write jobs: + update-initial-status: + runs-on: ubuntu-latest + if: github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Set pending commit status + uses: mattermost/actions/delivery/update-commit-status@fec7b836001c9380d4bfaf28d443945c103a098c + env: + GITHUB_TOKEN: ${{ github.token }} + with: + repository_full_name: ${{ github.repository }} + commit_sha: ${{ github.event.pull_request.head.sha }} + context: "docs-preview / preview" + description: "Docs preview build for ${{ github.event.pull_request.head.sha }} is running" + status: pending + deploy: uses: ./.github/workflows/docs-preview-template.yml if: github.event.pull_request.head.repo.full_name == github.repository + needs: + - update-initial-status secrets: AWS_DOCS_PR_PREVIEW_KEY_ID: ${{ secrets.AWS_DOCS_PR_PREVIEW_KEY_ID }} AWS_DOCS_PR_PREVIEW_SECRET_ACCESS_KEY: ${{ secrets.AWS_DOCS_PR_PREVIEW_SECRET_ACCESS_KEY }} with: PR_NUMBER: ${{ github.event.number }} - TRIGGERING_ACTOR: ${{ github.event.pull_request.user.login }} COMMIT_SHA: ${{ github.event.pull_request.head.sha }} + + update-failure-status: + runs-on: ubuntu-latest + if: failure() || cancelled() + needs: + - deploy + steps: + - uses: mattermost/actions/delivery/update-commit-status@fec7b836001c9380d4bfaf28d443945c103a098c + env: + GITHUB_TOKEN: ${{ github.token }} + with: + repository_full_name: ${{ github.repository }} + commit_sha: ${{ github.event.pull_request.head.sha }} + context: "docs-preview / preview" + description: "Docs preview build for ${{ github.event.pull_request.head.sha }} failed" + status: failure + + update-success-status: + runs-on: ubuntu-latest + if: success() + needs: + - deploy + steps: + - uses: mattermost/actions/delivery/update-commit-status@fec7b836001c9380d4bfaf28d443945c103a098c + env: + GITHUB_TOKEN: ${{ github.token }} + with: + repository_full_name: ${{ github.repository }} + commit_sha: ${{ github.event.pull_request.head.sha }} + context: "docs-preview / preview" + description: "Docs preview build for ${{ github.event.pull_request.head.sha }} succeeded" + status: success + target_url: "http://${{ vars.DOCS_PREVIEW_BUCKET_NAME }}.s3-website-us-east-1.amazonaws.com/mattermost/pr-${{ github.event.number }}/"