Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/dev_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ concurrency:
cancel-in-progress: true

permissions:
contents: read
# Required for the GraphQL convertPullRequestToDraft mutation.
contents: write
Comment thread
Reranko05 marked this conversation as resolved.
pull-requests: write
issues: write

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/dev_pr/title_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,41 @@ async function commentOpenGitHubIssue(github, context, pullRequestNumber) {
});
}

/**
* Converts the pull request to draft.
*
* @param {Object} github
* @param {Object} context
*/
async function convertToDraft(github, context) {
if (context.payload.pull_request.draft) {
return;
}

await github.graphql(
`
mutation ($pullRequestId: ID!) {
convertPullRequestToDraft(
input: {pullRequestId: $pullRequestId}
) {
pullRequest {
id
}
}
}
`,
{
pullRequestId: context.payload.pull_request.node_id,
},
);
}

module.exports = async ({github, context}) => {
const pullRequestNumber = context.payload.number;
const title = context.payload.pull_request.title;
const issue = helpers.detectIssue(title)
if (!issue) {
await commentOpenGitHubIssue(github, context, pullRequestNumber);
await convertToDraft(github, context);
}
};
Loading