Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(update-webhooks): remove classes from elements #646

Merged
merged 6 commits into from Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3,026 changes: 600 additions & 2,426 deletions cache/api.github.com/webhook-events-and-payloads.html

Large diffs are not rendered by default.

13,915 changes: 6,927 additions & 6,988 deletions cache/ghes-221/webhook-events-and-payloads.html

Large diffs are not rendered by default.

17,117 changes: 8,134 additions & 8,983 deletions cache/ghes-222/webhook-events-and-payloads.html

Large diffs are not rendered by default.

2,034 changes: 480 additions & 1,554 deletions cache/ghes-30/webhook-events-and-payloads.html

Large diffs are not rendered by default.

2,094 changes: 467 additions & 1,627 deletions cache/ghes-31/webhook-events-and-payloads.html

Large diffs are not rendered by default.

2,094 changes: 467 additions & 1,627 deletions cache/ghes-32/webhook-events-and-payloads.html

Large diffs are not rendered by default.

2,184 changes: 486 additions & 1,698 deletions cache/ghes-33/webhook-events-and-payloads.html

Large diffs are not rendered by default.

1,835 changes: 413 additions & 1,422 deletions cache/github.ae/webhook-events-and-payloads.html

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion lib/get-html.ts
Expand Up @@ -29,7 +29,28 @@ export const getHtml = async (

// get only the HTML we care about to avoid unnecessary cache updates
$('[data-testid="callout"]').remove();
const html = $("#article-contents").parent().parent().html() ?? "";
const data = $("#article-contents").parent().parent();
// Remove all classes from the HTML, except the ones that are actively used in the code to get payload examples.
// This is done to avoid unnecessary cache updates in order to reduce noise from automated Pull Requests
// https://github.com/octokit/webhooks/issues/642
data.find("*").each((i, el) => {
const classes = $(el).attr("class");

if (classes) {
const filteredClasses = classes
.split(" ")
.filter((classSelector) =>
["language-json", "warning"].includes(classSelector)
);

if (filteredClasses.length) {
$(el).attr("class", filteredClasses.join(" "));
} else {
$(el).removeAttr("class");
}
}
});
wolfy1339 marked this conversation as resolved.
Show resolved Hide resolved
const html = data.html() ?? "";

await cache.write(cacheFilePath, prettier.format(html, { parser: "html" }));

Expand Down
28 changes: 0 additions & 28 deletions payload-examples/api.github.com/index.json
Expand Up @@ -56415,34 +56415,6 @@
}
]
},
{
"name": "security_and_analysis",
"description": "Activity related to enabling or disabling code security and analysis features for a repository or organization.",
"properties": {
"changes": {
"type": "object",
"description": "The changes that were made to the code security and analysis features."
},
"repository": {
"type": "object",
"description": "The [`repository`](https://docs.github.com/en/rest/reference/repos#get-a-repository) where the event occurred."
},
"organization": {
"type": "object",
"description": "Webhook payloads contain the [`organization`](https://docs.github.com/en/rest/reference/orgs#get-an-organization) object when the webhook is configured for an organization or the event occurs from activity in a repository owned by an organization."
},
"installation": {
"type": "object",
"description": "The GitHub App installation. Webhook payloads contain the `installation` property when the event is configured for and sent to a GitHub App."
},
"sender": {
"type": "object",
"description": "The user that triggered the event."
}
},
"actions": [],
"examples": []
},
{
"name": "sponsorship",
"description": "Activity related to a sponsorship listing. The type of activity is specified in the `action` property of the payload object. For more information, see \"[About GitHub Sponsors](https://docs.github.com/en/sponsors/getting-started-with-github-sponsors/about-github-sponsors)\".\n\nYou can only create a sponsorship webhook on GitHub. For more information, see \"[Configuring webhooks for events in your sponsored account](https://docs.github.com/en/sponsors/integrating-with-github-sponsors/configuring-webhooks-for-events-in-your-sponsored-account)\".",
Expand Down