forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_pr_details.js
More file actions
23 lines (19 loc) · 736 Bytes
/
save_pr_details.js
File metadata and controls
23 lines (19 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module.exports = async ({github, context, core}) => {
const fs = require('fs');
const filename = "pr.txt";
const labelsData = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: (context.payload.issue || context.payload.pull_request || context.payload).number,
});
const labels = labelsData.data.map((label) => {
return label['name'];
});
try {
fs.writeFileSync(`./${filename}`, JSON.stringify({...context.payload, ...{labels:labels.join(",")}}));
return `PR successfully saved ${filename}`
} catch (err) {
core.setFailed("Failed to save PR details");
console.error(err);
}
}