3232 script : |
3333 let prNumber;
3434 let pr;
35-
35+
3636 if (context.eventName === 'workflow_dispatch') {
3737 prNumber = ${{ inputs.pr_number || 0 }};
3838 const { data } = await github.rest.pulls.get({
@@ -45,33 +45,33 @@ jobs:
4545 pr = context.payload.pull_request;
4646 prNumber = pr.number;
4747 }
48-
48+
4949 // Check if head repo still exists (can be null if fork was deleted)
5050 if (!pr.head.repo) {
5151 core.setFailed('Cannot complete this PR: the source repository (fork) has been deleted.');
5252 return;
5353 }
54-
54+
5555 // Check if this is a fork PR
5656 const isFork = pr.head.repo.fork || pr.head.repo.full_name !== pr.base.repo.full_name;
57-
57+
5858 // For fork PRs, check if maintainer can modify (push to the branch)
5959 const maintainerCanModify = pr.maintainer_can_modify;
60-
60+
6161 // Determine if we can proceed
6262 // - Non-fork PRs: always allowed (maintainers have push access)
6363 // - Fork PRs: only if maintainer_can_modify is true
6464 const canProceed = !isFork || maintainerCanModify;
65-
65+
6666 if (!canProceed) {
6767 core.setFailed(`Cannot complete this fork PR: the fork owner has not enabled "Allow edits from maintainers". PR author needs to enable this setting.`);
6868 return;
6969 }
70-
70+
7171 // Get the clone URL for the head repo (fork or base)
7272 const headRepoFullName = pr.head.repo.full_name;
7373 const headRepoCloneUrl = pr.head.repo.clone_url;
74-
74+
7575 // Set outputs for use in subsequent steps
7676 core.setOutput('pr_number', prNumber);
7777 core.setOutput('pr_title', pr.title);
8282 core.setOutput('head_repo_clone_url', headRepoCloneUrl);
8383 core.setOutput('maintainer_can_modify', maintainerCanModify);
8484 core.setOutput('can_proceed', canProceed);
85-
85+
8686 console.log(`PR #${prNumber}: "${pr.title}"`);
8787 console.log(`Author: ${pr.user.login}`);
8888 console.log(`Branch: ${pr.head.ref}`);
@@ -105,7 +105,7 @@ jobs:
105105 # Build fork-specific instructions if this is a fork PR
106106 if [ "$IS_FORK" = "true" ]; then
107107 CLONE_INSTRUCTIONS="This is a fork PR. Clone from the fork repository: ${HEAD_REPO_FULL_NAME}
108-
108+
109109 To check out this PR:
110110 1. Clone the fork: git clone https://github.com/${HEAD_REPO_FULL_NAME}.git
111111 2. Check out the branch: git checkout ${PR_BRANCH}
@@ -137,6 +137,8 @@ jobs:
137137 7. Commit your changes with clear commit messages.
138138 8. Push your changes to the PR branch.
139139 9. Post a summary comment on the PR explaining what you completed.
140+ 10. Remove the 'stale' label from the PR if you've completed the work.
141+ 11. Mark the PR as ready for review if applicable.
140142
141143 Rules and Guidelines:
142144 1. Respect the original author's intent and approach - don't rewrite the PR from scratch.
@@ -157,7 +159,7 @@ jobs:
157159 title: $title,
158160 tags: ["stale-pr-completion", "pr-'${PR_NUMBER}'"]
159161 }')")
160-
162+
161163 SESSION_URL=$(echo "$RESPONSE" | jq -r '.url // .session_url // empty')
162164 if [ -n "$SESSION_URL" ]; then
163165 echo "Devin session created: $SESSION_URL"
0 commit comments