Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save smitmartijn/4717c9f416a0d386dc61339c115f9f2c to your computer and use it in GitHub Desktop.
Save smitmartijn/4717c9f416a0d386dc61339c115f9f2c to your computer and use it in GitHub Desktop.
const fullTextRaw = $json["body"]["text"] || "";
const fullText = fullTextRaw.trim(); // remove leading/trailing whitespace
const lines = fullText.split('\n').map(line => line.trim());
// Look for lines
const summaryLine = lines.find(line => line.includes("Cloudflare Pages:"));
const commitLine = lines.find(line => line.startsWith("Commit Hash:"));
const envLine = lines.find(line => line.startsWith("Environment:"));
// If any line is missing, exit the workflow
if (!summaryLine || !commitLine || !envLine) {
return ""; // returning an empty array stops further execution
}
const filteredMessage = [summaryLine, commitLine, envLine].join('\n');
return {
json: {
message: filteredMessage
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment