-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: heitorlessa <lessa@amazon.co.uk>
- Loading branch information
1 parent
2d4df8a
commit 06965bb
Showing
10 changed files
with
234 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = async ({github, context, core}) => { | ||
const fs = require('fs'); | ||
|
||
const workflowRunId = process.env.WORKFLOW_ID; | ||
core.info(`Listing artifacts for workflow run ${workflowRunId}`); | ||
|
||
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: workflowRunId, | ||
}); | ||
|
||
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({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
|
||
core.info("Saving artifact found", artifact); | ||
|
||
fs.writeFileSync('pr.zip', Buffer.from(artifact.data)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = async ({github, context, core}) => { | ||
const prBody = process.env.PR_BODY; | ||
const prNumber = process.env.PR_NUMBER; | ||
const blockLabel = process.env.BLOCK_LABEL; | ||
const blockReasonLabel = process.env.BLOCK_REASON_LABEL; | ||
|
||
const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?<issue>\d+)/; | ||
|
||
const isMatch = RELATED_ISSUE_REGEX.exec(prBody); | ||
if (isMatch == null) { | ||
core.info(`No related issue found, maybe the author didn't use the template but there is one.`) | ||
|
||
let msg = "No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure."; | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: msg, | ||
issue_number: prNumber, | ||
}); | ||
|
||
return await github.rest.issues.addLabels({ | ||
issue_number: prNumber, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: [blockLabel, blockReasonLabel] | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module.exports = async ({github, context, core}) => { | ||
const pr_number = process.env.PR_NUMBER | ||
const pr_title = process.env.PR_TITLE | ||
|
||
console.log(pr_title) | ||
|
||
const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ | ||
const BUG_REGEX = /(fix|bug)(\((.+)\))?(\:.+)/ | ||
const DOCS_REGEX = /(docs|doc)(\((.+)\))?(\:.+)/ | ||
const CHORE_REGEX = /(chore)(\((.+)\))?(\:.+)/ | ||
const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(\:.+)/ | ||
const REFACTOR_REGEX = /(refactor)(\((.+)\))?(\:.+)/ | ||
|
||
const labels = { | ||
"feature": FEAT_REGEX, | ||
"bug": BUG_REGEX, | ||
"documentation": DOCS_REGEX, | ||
"internal": CHORE_REGEX, | ||
"enhancement": REFACTOR_REGEX, | ||
"deprecated": DEPRECATED_REGEX, | ||
} | ||
|
||
for (const label in labels) { | ||
const matcher = new RegExp(labels[label]) | ||
const isMatch = matcher.exec(pr_title) | ||
if (isMatch != null) { | ||
console.info(`Auto-labeling PR ${pr_number} with ${label}`) | ||
|
||
await github.rest.issues.addLabels({ | ||
issue_number: pr_number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: [label] | ||
}) | ||
|
||
break | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.