Skip to content
Merged
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
12 changes: 11 additions & 1 deletion scripts/src/actions/find-sha-for-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,29 @@ async function findShaForPlan(): Promise<string> {
const github = await GitHub.getGitHub()

if (context.eventName !== 'push') {
console.log(
`This is not a push event ("${context.eventName}"); returning "${context.sha}"`
)
return context.sha
}

const q = `repo:${context.repo.owner}/${context.repo.repo} ${context.sha} type:pr is:merged`
console.log(`Running advanced query: ${q}`)
const pulls = await github.client.paginate(
github.client.search.issuesAndPullRequests,
{
q: `repository:${context.repo.owner}/${context.repo.repo} ${context.sha} type:pr is:merged`,
q,
advanced_search: 'true'
}
)

if (pulls.length === 0) {
console.log('Got 0 pull request, returning empty string')
return ''
}

const pull = pulls[0]
console.log(`Processing pull request number ${pull.number}`)
const commits = await github.client.paginate(
github.client.pulls.listCommits,
{
Expand All @@ -31,9 +38,12 @@ async function findShaForPlan(): Promise<string> {
)

if (commits.length === 0) {
console.log('Found 0 commits, returning empty string')
return ''
}

const commit = commits[commits.length - 1]
console.log(`Returning commit ${commit.sha}`)
return commits[commits.length - 1].sha
}

Expand Down