mirror of
https://github.com/webiny/action-conventional-commits.git
synced 2024-11-27 04:03:49 +01:00
Merge pull request #2 from dkhunt27/prev
updated package versions; added some additional logging
This commit is contained in:
commit
b4fec2d1ec
4 changed files with 12715 additions and 25285 deletions
28716
dist/main/index.js
vendored
28716
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
9219
package-lock.json
generated
Normal file
9219
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,18 +6,17 @@
|
||||||
"author": "Adrian Smijulj <adrian1358@gmail.com>",
|
"author": "Adrian Smijulj <adrian1358@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.0.3",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^2.1.1",
|
"got": "^11.8.6",
|
||||||
"got": "^11.3.0",
|
|
||||||
"lodash.get": "^4.4.2"
|
"lodash.get": "^4.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.38.1",
|
|
||||||
"@babel/core": "^7.10.2",
|
"@babel/core": "^7.10.2",
|
||||||
"@babel/preset-env": "^7.10.2",
|
"@babel/preset-env": "^7.10.2",
|
||||||
"@babel/preset-typescript": "^7.10.1",
|
"@babel/preset-typescript": "^7.10.1",
|
||||||
"@types/jest": "^26.0.0",
|
"@types/jest": "^26.0.0",
|
||||||
|
"@vercel/ncc": "^0.38.1",
|
||||||
"babel-jest": "^26.0.1",
|
"babel-jest": "^26.0.1",
|
||||||
"jest": "^26.0.1",
|
"jest": "^26.0.1",
|
||||||
"prettier": "^2.0.2",
|
"prettier": "^2.0.2",
|
||||||
|
|
|
@ -6,33 +6,51 @@ type Commit = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const extractCommits = async (context, core): Promise<Commit[]> => {
|
const extractCommits = async (context, core): Promise<Commit[]> => {
|
||||||
|
|
||||||
|
core.debug(`context.payload.commits: ${JSON.stringify(context.payload.commits, null, 2)}\n`);
|
||||||
|
core.debug(`context.payload.pull_request: ${JSON.stringify(context.payload.pull_request, null, 2)}\n`);
|
||||||
|
|
||||||
// For "push" events, commits can be found in the "context.payload.commits".
|
// For "push" events, commits can be found in the "context.payload.commits".
|
||||||
const pushCommits = Array.isArray(get(context, "payload.commits"));
|
const pushCommits = Array.isArray(get(context, "payload.commits"));
|
||||||
if (pushCommits) {
|
if (pushCommits) {
|
||||||
|
core.info(`detected a "push"; using those commits`);
|
||||||
return context.payload.commits;
|
return context.payload.commits;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For PRs, we need to get a list of commits via the GH API:
|
const pull_request = get(context, "payload.pull_request");
|
||||||
const prCommitsUrl = get(context, "payload.pull_request.commits_url");
|
if (!pull_request) {
|
||||||
if (prCommitsUrl) {
|
core.warnMsg("Push or Pull Request not detected; no commits to check");
|
||||||
try {
|
} else {
|
||||||
let requestHeaders = {
|
core.info(`detected a "pull request"; using those commits`);
|
||||||
"Accept": "application/vnd.github+json",
|
|
||||||
}
|
|
||||||
if (core.getInput('GITHUB_TOKEN') != "") {
|
|
||||||
requestHeaders["Authorization"] = "token " + core.getInput('GITHUB_TOKEN')
|
|
||||||
}
|
|
||||||
const { body } = await got.get(prCommitsUrl, {
|
|
||||||
responseType: "json",
|
|
||||||
headers: requestHeaders,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (Array.isArray(body)) {
|
const prCommitsUrl = get(pull_request, "commits_url");
|
||||||
return body.map((item) => item.commit);
|
if (prCommitsUrl) {
|
||||||
|
try {
|
||||||
|
let requestHeaders = {
|
||||||
|
"Accept": "application/vnd.github+json",
|
||||||
|
}
|
||||||
|
if (core.getInput('GITHUB_TOKEN') != "") {
|
||||||
|
requestHeaders["Authorization"] = "token " + core.getInput('GITHUB_TOKEN')
|
||||||
|
}
|
||||||
|
const { body } = await got.get(prCommitsUrl, {
|
||||||
|
responseType: "json",
|
||||||
|
headers: requestHeaders,
|
||||||
|
});
|
||||||
|
|
||||||
|
core.debug(`body extracted: ${JSON.stringify(body)}`);
|
||||||
|
core.info(`Commits extracted: ${(body as any)?.length}`);
|
||||||
|
|
||||||
|
if (Array.isArray(body)) {
|
||||||
|
return body.map((item) => item.commit);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
} catch (err) {
|
||||||
|
const msg = (err as any)?.message || err;
|
||||||
|
core.warnMsg(`Issue processing prCommitsUrl: ${msg}; no commits to check`);
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
return [];
|
} else {
|
||||||
} catch {
|
core.warnMsg("missing prCommitsUrl; no commits to check");
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue