Skip to content

Instantly share code, notes, and snippets.

@ipcrm
Created April 19, 2019 12:01
Show Gist options
  • Save ipcrm/699917efcca4dce6e76b309d0090030c to your computer and use it in GitHub Desktop.
Save ipcrm/699917efcca4dce6e76b309d0090030c to your computer and use it in GitHub Desktop.
Schedule Goals from PR Event
sdm.addPullRequestListener(async prl => {
const repo = await fetchBranchTips(
prl.context,
{
repo: prl.pullRequest.repo.name,
owner: prl.pullRequest.repo.owner,
providerId: prl.pullRequest.repo.org.provider.providerId,
},
);
const id = GitHubRepoRef.from({
owner: prl.pullRequest.repo.owner,
repo: prl.pullRequest.repo.name,
branch: prl.pullRequest.branch.name,
sha: repo.branches.filter(b => b.name === prl.pullRequest.branch.name)[0].commit.sha,
});
const push = await fetchPushForCommit(prl.context, id, repo.org.provider.providerId);
await chooseAndSetGoals({
projectLoader: sdm.configuration.sdm.projectLoader,
repoRefResolver: sdm.configuration.sdm.repoRefResolver,
goalsListeners: [...sdm.goalsSetListeners],
goalSetter: sdm.pushMapping,
implementationMapping: sdm.goalFulfillmentMapper,
}, {
context: prl.context,
credentials: prl.credentials,
push,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment