Skip to content

Filter doesn't work for columns UUID and INT with postgresql database #26

Filter doesn't work for columns UUID and INT with postgresql database

Filter doesn't work for columns UUID and INT with postgresql database #26

name: manage-issue
on:
issues:
types: [opened, edited]
jobs:
validate-issue:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
script: |
const user = context.payload.sender.login;
const issue = context.payload.issue;
const body = issue.body;
const STEPS_TO_REPRO_REGEXP = /### Steps to reproduce[\r\n]+([^#]+)###/m;
const SCREENSHOT_REGEXP = /### Screenshots[\n]+[\s\S]*(https:\/\/github\.com\/user-attachments\/assets\/)[\s\S]*### Additional context/m; //No need for any strictness here. Just loose sanity check
const LABEL_NEEDS_MORE_INFORMATION = "needs more info";
const LABEL_UNCONFIRMED = "unconfirmed";
function debug(...args) {
core.info(args.map(JSON.stringify).join(" "));
}
debug({user})
if (context.payload.comment) {
debug("Ignoring comment update.");
return;
}
const screenshotMatch = body.match(SCREENSHOT_REGEXP);
const stepsToReproMatch = body.match(STEPS_TO_REPRO_REGEXP);
const screenshotUrls = screenshotMatch !== null ? screenshotMatch[1]?.trim() : null;
const reproSteps = stepsToReproMatch !== null ? stepsToReproMatch[1]?.trim() : null;
debug({body});
debug({screenshotMatch});
debug({screenshotUrls});
debug({stepsToReproMatch});
debug({reproSteps});
async function createComment(comment) {
comment = comment
.split("\n")
.map((line) => line.trim())
.join("\n")
.trim();
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment,
});
}
async function getGitHubActionComments() {
const comments = await github.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
return comments.data.filter((comment) => {
debug(`comment by user: '${comment.user.login}'`);
return comment.user.login === "github-actions[bot]";
});
}
async function doesNotHaveNeedsMoreInfoLabel() {
const issues = await github.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
return (
issues.data.find((label) => label.name === LABEL_NEEDS_MORE_INFORMATION) ===
undefined
);
}
async function updateIssue(state, state_reason = null) {
await github.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state,
state_reason,
});
}
async function closeWithComment(comment) {
const payload = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [LABEL_NEEDS_MORE_INFORMATION],
};
debug(`Missing required information`);
await github.issues.addLabels(payload);
await createComment(comment);
await updateIssue("closed", "not_planned");
}
async function openWithComment(comment) {
const isMissingLabel = await doesNotHaveNeedsMoreInfoLabel();
if (isMissingLabel) {
debug(`Likely new Issue: the Issue was not tagged as needs information`);
return;
}
const comments = await getGitHubActionComments();
if (comments.length === 0) {
debug(`Issue was closed by someone else, won't reopen`);
return;
}
debug(`Reopening closed issue`);
await github.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: LABEL_NEEDS_MORE_INFORMATION,
});
await createComment(comment);
await updateIssue("open");
}
const NO_REPRO_STEPS = reproSteps?.length < 25;
const NO_SCREENSHOTS = !screenshotUrls ;
if( !NO_REPRO_STEPS && !NO_SCREENSHOTS ) {
debug('all good');
openWithComment(`Thank you for adding needed details! This issue is now re-opened.`);
return;
}
const maintainsers = [
'damms005',
];
if (maintainsers.includes(user) ) {
debug(`Maintainer ${user} is exempt from this check`);
return;
}
const isClosed = issue.state !== "open"
let comment = isClosed
? `Hey @${user}! Thanks for updating this issue. 💛`
: `Hey @${user}! We're sorry to hear that you've hit this issue. 💛`;
comment += `
However, `
if (NO_SCREENSHOTS) {
comment += `it looks like you forgot to provide screenshots. A picture is worth more than a thousand words. Please edit your original post and add screenshots, then we'll try and fix this issue.
We need screenshots to make it easier for us to visualize your issue, since your description of this bug as you described above may not paint the full picture. **Do ensure that your screenshot does not include anything that should not be made public**.
Please upload your screenshot files directly to GitHub.`;
}
if (NO_SCREENSHOTS && NO_REPRO_STEPS) {
comment += `
Also, `;
}
if (!NO_SCREENSHOTS && NO_REPRO_STEPS) {
comment += `
However, `;
}
if (NO_REPRO_STEPS) {
comment += ` it doesn't look like you've provided much information on how to replicate the issue. Please edit your original post with clear steps needed to recreate this issue.`;
}
closeWithComment(comment);