@aircall/ci-scripts
Advanced tools
Comparing version 2.5.3 to 2.6.3
const { post } = require('../request.js'); | ||
const { checkEnvVariables } = require('../helpers.js'); | ||
const { | ||
getMergedPullRequests, | ||
getPullRequest, | ||
getReleaseFromSha1, | ||
@@ -123,3 +123,3 @@ getPreviousReleaseFromRelease, | ||
} else { | ||
mergedPR = await getPRData(CIRCLE_SHA1); | ||
mergedPR = await getPullRequest(CIRCLE_SHA1); | ||
lastDraft = await getLatestDraft(); | ||
@@ -148,12 +148,2 @@ | ||
const getPRData = async commitish => { | ||
const prs = await getMergedPullRequests(); | ||
const mergedPR = prs.find(pr => { | ||
return pr.mergeCommit.oid === commitish; | ||
}); | ||
return mergedPR; | ||
}; | ||
const notifySlack = async (environment, channel, title = ':ship:') => { | ||
@@ -160,0 +150,0 @@ const isRollback = title === 'rollback'; |
@@ -173,21 +173,27 @@ const { get, patch, post } = require('./request.js'); | ||
const getMergedPullRequests = async () => { | ||
const prFragment = ` | ||
nodes { | ||
title | ||
number | ||
mergedAt | ||
url | ||
baseRefName | ||
author { | ||
login | ||
avatarUrl | ||
} | ||
mergeCommit { | ||
oid | ||
committedDate | ||
} | ||
} | ||
` | ||
const getPullRequest = async commitish => { | ||
const repository = `owner: "${CIRCLE_PROJECT_USERNAME}", name: "${CIRCLE_PROJECT_REPONAME}"`; | ||
const query = `{repository(${repository}) { | ||
pullRequests(states: MERGED, last: 100, baseRefName: "master") { | ||
edges { | ||
node { | ||
title | ||
number | ||
mergedAt | ||
url | ||
baseRefName | ||
author { | ||
login | ||
avatarUrl | ||
} | ||
mergeCommit { | ||
oid | ||
committedDate | ||
} | ||
object(oid: "${commitish}") { | ||
... on Commit { | ||
associatedPullRequests(first: 1) { | ||
${prFragment} | ||
} | ||
@@ -197,2 +203,15 @@ } | ||
} | ||
}` | ||
const pullRequestData = await executeGraphQLRequest(query); | ||
return pullRequestData.data.repository.object.associatedPullRequests.nodes[0] | ||
} | ||
const getMergedPullRequests = async () => { | ||
const repository = `owner: "${CIRCLE_PROJECT_USERNAME}", name: "${CIRCLE_PROJECT_REPONAME}"`; | ||
const query = `{repository(${repository}) { | ||
pullRequests(states: MERGED, last: 100, baseRefName: "master") { | ||
${prFragment} | ||
} | ||
} | ||
}`; | ||
@@ -219,4 +238,5 @@ | ||
getReleaseFromSha1, | ||
getPullRequest, | ||
getPreviousReleaseFromRelease, | ||
getPreviousReleaseFromSha1 | ||
}; |
{ | ||
"name": "@aircall/ci-scripts", | ||
"version": "2.5.3", | ||
"version": "2.6.3", | ||
"dependencies": {}, | ||
@@ -5,0 +5,0 @@ "main": "ci-scripts.js", |
38747
975