From b0850c652354b607920cb451d9e70d25fb1c0db3 Mon Sep 17 00:00:00 2001 From: Amy Blais <29708087+amyblais@users.noreply.github.com> Date: Fri, 10 Jul 2026 10:59:55 +0300 Subject: [PATCH 1/5] Docs automation fixes --- .github/workflows/docs-pr-sync.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docs-pr-sync.yml b/.github/workflows/docs-pr-sync.yml index e12287c4119..54267e934df 100644 --- a/.github/workflows/docs-pr-sync.yml +++ b/.github/workflows/docs-pr-sync.yml @@ -22,9 +22,9 @@ # and updates labels on the original dev PR: # Removes Docs/Needed # Adds Docs/Done - + name: "Docs PR Sync - Update Dev PR Labels on Close" - + on: pull_request: types: [closed] @@ -34,7 +34,7 @@ on: description: 'Docs branch name to simulate closing (e.g. docs/mattermost-pr-1234)' required: true type: string - + jobs: sync-labels: name: "Remove Docs/Needed, Add Docs/Done on dev PR" @@ -48,7 +48,7 @@ jobs: github.event_name == 'workflow_dispatch' || (startsWith(github.event.pull_request.head.ref, 'docs/') && github.event.pull_request.head.repo.full_name == github.repository) - + steps: # 0. Generate a short-lived write token scoped to the three engineering # repos. Uses the shared changelog write app so the token is not tied @@ -57,13 +57,13 @@ jobs: id: token uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 with: - app-id: ${{ vars.CHANGELOG_PR_CLIENT_ID }} + client-id: ${{ vars.CHANGELOG_PR_CLIENT_ID }} private-key: ${{ secrets.CHANGELOG_PR_PRIVATE_KEY }} repositories: >- mattermost, mattermost-mobile, desktop - + # 1. Parse dev PR reference from branch name # Branch format: docs/-pr- # e.g. docs/mattermost-pr-1234 -> mattermost/mattermost#1234 @@ -81,15 +81,15 @@ jobs: fi REPO_NAME="${BASH_REMATCH[1]}" PR_NUMBER="${BASH_REMATCH[2]}" - + FULL_REPO="mattermost/${REPO_NAME}" - + echo "repo_name=$REPO_NAME" >> "$GITHUB_OUTPUT" echo "full_repo=$FULL_REPO" >> "$GITHUB_OUTPUT" echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" - + echo "Dev PR resolved to: ${FULL_REPO}#${PR_NUMBER}" - + # 2. Update labels on the dev PR # Docs/Done is applied whether the docs PR was merged OR closed without # merging. An abandoned docs PR means the developer is handling docs @@ -104,7 +104,7 @@ jobs: DOCS_PR_MERGED: ${{ github.event.pull_request.merged }} run: | echo "Updating labels on ${DEV_REPO}#${DEV_PR}..." - + # Remove Docs/Needed (soft-fail - label may already be absent) if gh pr edit "$DEV_PR" --repo "$DEV_REPO" \ --remove-label "Docs/Needed" 2>/dev/null; then @@ -112,12 +112,12 @@ jobs: else echo " Docs/Needed not present or could not be removed - continuing" fi - + # Add Docs/Done (hard-fail - this must succeed) # Applied for both merged and closed-without-merging; see comment above. gh pr edit "$DEV_PR" --repo "$DEV_REPO" --add-label "Docs/Done" echo " Added Docs/Done" - + # 3. Comment on the dev PR # Skipped for workflow_dispatch: there is no real docs PR being closed, # so github.event.pull_request.number is empty and the link would be broken. @@ -135,10 +135,10 @@ jobs: else STATUS="closed without merging" fi - + DOCS_LINK="[mattermost/docs#${DOCS_PR_NUMBER}]" DOCS_LINK="${DOCS_LINK}(https://github.com/mattermost/docs/pull/${DOCS_PR_NUMBER})" - + gh pr comment "$DEV_PR" \ --repo "$DEV_REPO" \ --body "The associated docs PR ${DOCS_LINK} has been **${STATUS}**. Label updated: Docs/Needed -> Docs/Done." From 3e99f84678e69cbd53db868a8c26ce36a56be5e4 Mon Sep 17 00:00:00 2001 From: Amy Blais <29708087+amyblais@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:01:02 +0300 Subject: [PATCH 2/5] Update docs-branch-create.yml --- .github/workflows/docs-branch-create.yml | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docs-branch-create.yml b/.github/workflows/docs-branch-create.yml index d6b7c072e72..9fbcc3067a0 100644 --- a/.github/workflows/docs-branch-create.yml +++ b/.github/workflows/docs-branch-create.yml @@ -25,9 +25,9 @@ # There is only one active docs branch at a time. This branch becomes the # base target for all Docs/Needed PRs in the new cycle # (see docs-needed.yml in the code repos). - + name: Create Next Version Docs Branch - + on: pull_request: types: [closed] @@ -38,7 +38,7 @@ on: description: 'Branch name to simulate merging (e.g. v11.6-documentation)' required: true type: string - + jobs: create-next-version-branch: name: Create docs branch for next milestone @@ -57,7 +57,7 @@ jobs: github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.event.pull_request.head.ref, 'v') && endsWith(github.event.pull_request.head.ref, '-documentation')) - + steps: # 0. Generate a short-lived read token scoped to mattermost/mattermost # for milestone reads. Uses the shared changelog read app so the token @@ -66,10 +66,10 @@ jobs: id: token uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 with: - app-id: ${{ vars.CHANGELOG_READ_CLIENT_ID }} + client-id: ${{ vars.CHANGELOG_READ_CLIENT_ID }} private-key: ${{ secrets.CHANGELOG_READ_PRIVATE_KEY }} repositories: mattermost - + # 1. Strict branch name validation # The job-level if: is a broad pre-filter (GitHub Actions expressions # do not support regex). This step enforces the exact pattern @@ -86,7 +86,7 @@ jobs: fi echo "Branch validated: ${MERGED_BRANCH}" echo "Looking for the next open milestone in mattermost/mattermost..." - + # 2. Find the next open milestone in mattermost/mattermost # "Next" means the earliest open milestone whose version is strictly # greater than the branch that just merged. Filtering by version @@ -106,7 +106,7 @@ jobs: MERGED_MAJOR="${BASH_REMATCH[1]}" MERGED_MINOR="${BASH_REMATCH[2]}" echo "Merged: v${MERGED_MAJOR}.${MERGED_MINOR} — looking for the next open milestone..." - + # Find open milestones with a version strictly greater than the merged # branch. Sort by due date (nulls last) then title; take the first. # --arg passes MERGED_MAJOR/MINOR as strings; tonumber converts inside jq. @@ -131,36 +131,36 @@ jobs: first | .title ' - + + # Pipe to standalone jq with --arg — gh api does not support --arg. NEXT_TITLE=$(gh api repos/mattermost/mattermost/milestones \ --paginate \ - --jq "$JQ_FILTER" \ - --arg maj "$MERGED_MAJOR" \ - --arg min "$MERGED_MINOR") - + | jq -r --arg maj "$MERGED_MAJOR" --arg min "$MERGED_MINOR" \ + "$JQ_FILTER") + if [ -z "$NEXT_TITLE" ] || [ "$NEXT_TITLE" == "null" ]; then echo "::warning::No open milestone found with version >" \ "v${MERGED_MAJOR}.${MERGED_MINOR} in mattermost/mattermost - no branch created." echo "found=false" >> "$GITHUB_OUTPUT" exit 0 fi - + # Derive the docs branch name: extract vMAJOR.MINOR, append -documentation # e.g. "v11.7.0" -> "v11.7-documentation" VERSION=$(echo "$NEXT_TITLE" | grep -oE 'v[0-9]+\.[0-9]+' | head -1) - + if [ -z "$VERSION" ]; then echo "::error::Could not parse a vMAJOR.MINOR version from milestone '${NEXT_TITLE}'." exit 1 fi - + DOCS_BRANCH="${VERSION}-documentation" - + echo "found=true" >> "$GITHUB_OUTPUT" echo "title=$NEXT_TITLE" >> "$GITHUB_OUTPUT" echo "branch=$DOCS_BRANCH" >> "$GITHUB_OUTPUT" echo "Next milestone: $NEXT_TITLE -> docs branch: $DOCS_BRANCH" - + # 3. Create the branch in mattermost/docs - name: Create docs branch id: create_branch @@ -172,24 +172,24 @@ jobs: # Check whether the branch already exists (idempotent) EXISTS=$(gh api "repos/mattermost/docs/branches/${BRANCH}" \ --jq '.name' 2>/dev/null || echo "") - + if [ -n "$EXISTS" ]; then echo "created=false" >> "$GITHUB_OUTPUT" echo "::notice::Branch '${BRANCH}' already exists in mattermost/docs - nothing to do." exit 0 fi - + # Branch from the tip of master SHA=$(gh api repos/mattermost/docs/branches/master --jq '.commit.sha') - + gh api repos/mattermost/docs/git/refs \ --method POST \ -f "ref=refs/heads/${BRANCH}" \ -f "sha=${SHA}" - + echo "created=true" >> "$GITHUB_OUTPUT" echo "Created branch '${BRANCH}' in mattermost/docs from master (${SHA})" - + # 4. Post a summary - name: Summary if: steps.milestone.outputs.found == 'true' From e2c69750693bf7d0f4e9c519ff8ee537ca888a13 Mon Sep 17 00:00:00 2001 From: Amy Blais <29708087+amyblais@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:10:35 +0300 Subject: [PATCH 3/5] Update docs-branch-create.yml --- .github/workflows/docs-branch-create.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs-branch-create.yml b/.github/workflows/docs-branch-create.yml index 9fbcc3067a0..1bc1168bce6 100644 --- a/.github/workflows/docs-branch-create.yml +++ b/.github/workflows/docs-branch-create.yml @@ -110,7 +110,11 @@ jobs: # Find open milestones with a version strictly greater than the merged # branch. Sort by due date (nulls last) then title; take the first. # --arg passes MERGED_MAJOR/MINOR as strings; tonumber converts inside jq. + # --paginate emits one JSON array per page. -s slurps all pages into + # a single outer array; add flattens [[page1...],[page2...]] → [...]. + # Without -s, sort_by|first runs once per page — wrong across pages. JQ_FILTER=' + add | [ .[] | select( .state == "open" and @@ -135,7 +139,7 @@ jobs: # Pipe to standalone jq with --arg — gh api does not support --arg. NEXT_TITLE=$(gh api repos/mattermost/mattermost/milestones \ --paginate \ - | jq -r --arg maj "$MERGED_MAJOR" --arg min "$MERGED_MINOR" \ + | jq -rs --arg maj "$MERGED_MAJOR" --arg min "$MERGED_MINOR" \ "$JQ_FILTER") if [ -z "$NEXT_TITLE" ] || [ "$NEXT_TITLE" == "null" ]; then From b6676e171e882307bda6380f525e3aa9ba07c00d Mon Sep 17 00:00:00 2001 From: Amy Blais <29708087+amyblais@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:21:40 +0300 Subject: [PATCH 4/5] Update docs-branch-create.yml --- .github/workflows/docs-branch-create.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs-branch-create.yml b/.github/workflows/docs-branch-create.yml index 1bc1168bce6..3ef69c731d2 100644 --- a/.github/workflows/docs-branch-create.yml +++ b/.github/workflows/docs-branch-create.yml @@ -1,4 +1,3 @@ ---- # .github/workflows/docs-branch-create.yml # # Place this file in: From a0faae5f35579271fa771af95aec8441f08cc376 Mon Sep 17 00:00:00 2001 From: Amy Blais <29708087+amyblais@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:21:44 +0300 Subject: [PATCH 5/5] Update docs-pr-sync.yml --- .github/workflows/docs-pr-sync.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs-pr-sync.yml b/.github/workflows/docs-pr-sync.yml index 54267e934df..2996e9e9e7d 100644 --- a/.github/workflows/docs-pr-sync.yml +++ b/.github/workflows/docs-pr-sync.yml @@ -1,4 +1,3 @@ ---- # .github/workflows/docs-pr-sync.yml # # Place this file in: