Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Nudge contributors to allow maintainer edits (#63204)
Lenab415b5d44793
diff --git a/.github/workflows/maintainer_edits_nudge.yml b/.github/workflows/maintainer_edits_nudge.ymlnew file mode 100644index 00000000000..baba93ede8d--- /dev/null+++ b/.github/workflows/maintainer_edits_nudge.yml@@ -0,0 +1,102 @@+name: Maintainer Edits Nudge++on:+ # zizmor: ignore[dangerous-triggers]+ # Fork PRs must be supported, but this workflow only reads GitHub metadata and+ # posts a comment; it never checks out or executes PR code.+ pull_request_target:+ types: [opened, reopened]++permissions: {}++concurrency:+ group: maintainer-edits-nudge-${{ github.event.pull_request.number }}+ cancel-in-progress: false++jobs:+ nudge-contributor:+ if: >-+ github.repository == 'zed-industries/zed'+ && github.event.pull_request.head.repo.full_name != null+ && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name+ && github.event.pull_request.user.type != 'Bot'+ && !contains(fromJSON('["MEMBER","OWNER"]'), github.event.pull_request.author_association)+ permissions:+ pull-requests: write+ runs-on: namespace-profile-2x4-ubuntu-2404+ timeout-minutes: 5++ steps:+ - name: Nudge contributor to allow maintainer edits+ uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1+ with:+ script: |+ const commentMarker = '<!-- zed-maintainer-edits-nudge -->';+ const repositoryOwner = context.repo.owner;+ const repositoryName = context.repo.repo;+ const pullRequestNumber = context.payload.pull_request.number;++ const { data: pullRequest } = await github.rest.pulls.get({+ owner: repositoryOwner,+ repo: repositoryName,+ pull_number: pullRequestNumber,+ });++ const headRepository = pullRequest.head.repo;+ const isCrossRepositoryPullRequest =+ headRepository &&+ headRepository.full_name !== pullRequest.base.repo.full_name;++ if (!isCrossRepositoryPullRequest || pullRequest.maintainer_can_modify) {+ return;+ }++ const headRepositoryOwnerType = headRepository.owner.type;+ if (+ headRepositoryOwnerType !== 'User' &&+ headRepositoryOwnerType !== 'Organization'+ ) {+ throw new Error(+ `Unsupported head repository owner type: ${headRepositoryOwnerType}`+ );+ }++ const existingComments = await github.paginate(+ github.rest.issues.listComments,+ {+ owner: repositoryOwner,+ repo: repositoryName,+ issue_number: pullRequestNumber,+ per_page: 100,+ }+ );+ const commentAlreadyExists = existingComments.some(+ comment =>+ comment.user?.login === 'github-actions[bot]' &&+ comment.body?.includes(commentMarker)+ );++ if (commentAlreadyExists) {+ return;+ }++ const commentBody = headRepositoryOwnerType === 'User'+ ? `${commentMarker}+ Thanks for contributing to Zed.++ Please enable **Allow edits from maintainers** for this pull request. [GitHub documents the setting and steps here](https://docs.github.com/en/pull-requests/how-tos/work-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).++ This lets a Zed maintainer apply small review fixes or update your branch from the pull request's base branch when needed. It reduces follow-up work for you and helps us merge an approved contribution without waiting for another round trip. Any changes we make will appear as commits in this pull request.`+ : `${commentMarker}+ Thanks for contributing to Zed.++ This pull request comes from an organization-owned fork. GitHub does not offer **Allow edits from maintainers** for organization-owned forks, so this pull request cannot grant Zed maintainers access to the branch.++ If your organization permits it, consider opening the contribution from a personal fork instead and enabling **Allow edits from maintainers**. [GitHub explains the setting here](https://docs.github.com/en/pull-requests/how-tos/work-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork). Otherwise, no action is needed now. Unless a maintainer already has write access to the fork, we may need to ask you to make branch updates before the pull request can be merged.`;++ await github.rest.issues.createComment({+ owner: repositoryOwner,+ repo: repositoryName,+ issue_number: pullRequestNumber,+ body: commentBody,+ });diff --git a/.github/workflows/slack_notify_community_automation_failure.yml b/.github/workflows/slack_notify_community_automation_failure.ymlindex d5c3fffdcf5..00efd431b7c 100644--- a/.github/workflows/slack_notify_community_automation_failure.yml+++ b/.github/workflows/slack_notify_community_automation_failure.yml@@ -14,6 +14,7 @@ on:- "Track duplicate bot effectiveness"- "Community PR Board"- "Community PR Cleanup"+ - "Maintainer Edits Nudge"- "PR Board Meta Fields Refresh"- "PR Issue Labeler"- "Guild Assignment Status"@@ -32,7 +33,7 @@ jobs:github.repository == 'zed-industries/zed'&& github.event.workflow_run.head_repository.full_name == github.repository&& contains(fromJSON('["issues","issue_comment","pull_request","pull_request_target","schedule","workflow_dispatch"]'), github.event.workflow_run.event)- && github.event.workflow_run.conclusion == 'failure'+ && contains(fromJSON('["failure","timed_out","startup_failure"]'), github.event.workflow_run.conclusion)runs-on: namespace-profile-2x4-ubuntu-2404steps: