Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 16 additions & 15 deletions .github/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
module.exports = Object.freeze({
/** @type {string} */
// Values: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
"PR_ACTION": process.env.PR_ACTION?.replace(/"/g, '') || "",
PR_ACTION: process.env.PR_ACTION?.replace(/"/g, '') || '',

/** @type {string} */
"PR_AUTHOR": process.env.PR_AUTHOR?.replace(/"/g, '') || "",
PR_AUTHOR: process.env.PR_AUTHOR?.replace(/"/g, '') || '',

/** @type {string} */
"PR_BODY": process.env.PR_BODY || "",
PR_BODY: process.env.PR_BODY || '',

/** @type {string} */
"PR_TITLE": process.env.PR_TITLE || "",
PR_TITLE: process.env.PR_TITLE || '',

/** @type {number} */
"PR_NUMBER": process.env.PR_NUMBER || 0,
PR_NUMBER: process.env.PR_NUMBER || 0,

/** @type {string} */
"PR_IS_MERGED": process.env.PR_IS_MERGED || "false",
PR_IS_MERGED: process.env.PR_IS_MERGED || 'false',

/** @type {string} */
"LABEL_BLOCK": "do-not-merge",
LABEL_BLOCK: 'do-not-merge',

/** @type {string} */
"LABEL_BLOCK_REASON": "need-issue",
LABEL_BLOCK_REASON: 'need-issue',

/** @type {string} */
"LABEL_PENDING_RELEASE": "pending-release",
LABEL_PENDING_RELEASE: 'pending-release',

/** @type {string} */
"LABEL_RELEASED": "completed",
LABEL_RELEASED: 'completed',

/** @type {string} */
"HANDLE_MAINTAINERS_TEAM": "@aws-powertools/lambda-typescript",
HANDLE_MAINTAINERS_TEAM: '@aws-powertools/lambda-typescript',

/** @type {string[]} */
"IGNORE_AUTHORS": ["dependabot[bot]"],
IGNORE_AUTHORS: ['dependabot[bot]'],

/** @type {RegExp} */
"RELATED_ISSUE_REGEX": /\b\*{0,2}[iI]ssue [nN]umber\*{0,2}:\*{0,2}\s*(?<closingWord>closes?|closed|fix|fixes?|fixed|resolves?|resolved)?\s*#(?<issue>\d+)\b/
});
RELATED_ISSUE_REGEX:
/\b\*{0,2}[iI]ssue [nN]umber\*{0,2}:\*{0,2}\s*(?<closingWord>closes?|closed|fix|fixes?|fixed|resolves?|resolved)?\s*#(?<issue>\d+)\b/,
});
12 changes: 7 additions & 5 deletions .github/scripts/download_pr_artifact.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = async ({github, context, core}) => {
const fs = require('fs');
const fs = require('node:fs');

module.exports = async ({ github, context, core }) => {
const workflowRunId = process.env.WORKFLOW_ID;
core.info(`Listing artifacts for workflow run ${workflowRunId}`);

Expand All @@ -10,7 +10,9 @@ module.exports = async ({github, context, core}) => {
run_id: workflowRunId,
});

const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0];
const matchArtifact = artifacts.data.artifacts.filter(
(artifact) => artifact.name === 'pr'
)[0];

core.info(`Downloading artifacts for workflow run ${workflowRunId}`);
const artifact = await github.rest.actions.downloadArtifact({
Expand All @@ -20,7 +22,7 @@ module.exports = async ({github, context, core}) => {
archive_format: 'zip',
});

core.info("Saving artifact found", artifact);
core.info('Saving artifact found', artifact);

fs.writeFileSync('pr.zip', Buffer.from(artifact.data));
}
};
7 changes: 3 additions & 4 deletions .github/scripts/label_pr_based_on_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ module.exports = async ({ github, context, core }) => {
});

return;
} else {
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`);
miss += 1;
}
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`);
miss += 1;
}
} finally {
if (miss == Object.keys(labels).length) {
if (miss === Object.keys(labels).length) {
core.notice(
`PR ${PR_NUMBER} title '${PR_TITLE}' contain any of the release-related types; skipping...`
);
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/label_related_issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = async ({ github, context, core }) => {
return core.notice('Author in IGNORE_AUTHORS list; skipping...');
}

if (PR_IS_MERGED == 'false') {
if (PR_IS_MERGED === 'false') {
return core.notice('Only merged PRs to avoid spam; skipping');
}

Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"type": "commonjs"
}
}
4 changes: 2 additions & 2 deletions .github/scripts/post_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const fetchIssues = async ({
});

return issues.filter(
(issue) => Object(issue).hasOwnProperty('pull_request') === false
(issue) => Object.hasOwn(Object(issue), 'pull_request') === false
);
} catch (error) {
core.setFailed(error);
Expand Down Expand Up @@ -84,7 +84,7 @@ const notifyRelease = async ({

// Remove staged label; keep existing ones
const labels = issue.labels
.filter((label) => label.name != LABEL_PENDING_RELEASE)
.filter((label) => label.name !== LABEL_PENDING_RELEASE)
.map((label) => label.name);

// Update labels including the released one
Expand Down
16 changes: 8 additions & 8 deletions .github/scripts/save_pr_details.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = async ({context, core}) => {
const fs = require('fs');
const filename = "pr.txt";
const fs = require('node:fs');
module.exports = async ({ context, core }) => {
const filename = 'pr.txt';

try {
fs.writeFileSync(`./${filename}`, JSON.stringify(context.payload));
fs.writeFileSync(`./${filename}`, JSON.stringify(context.payload));

return `PR successfully saved ${filename}`;
return `PR successfully saved ${filename}`;
} catch (err) {
core.setFailed("Failed to save PR details");
console.error(err);
core.setFailed('Failed to save PR details');
console.error(err);
}
}
};