Skip to content
New issue

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

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

Already on GitHub? # to your account

Add qol changes #221

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
62 changes: 47 additions & 15 deletions src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const update = async (shouldCommit = false) => {
.map((i) => i.trim())
.filter((i) => i.length);

if (dayjs(metadata.end).isBefore(dayjs())) {
if ((metadata.end !== "unknown") && dayjs(metadata.end).isBefore(dayjs())) {
await octokit.issues.unlock({
owner,
repo,
Expand Down Expand Up @@ -387,24 +387,56 @@ generator: Upptime <https://github.com/upptime/upptime>

// If the site was just recorded as down or degraded, open an issue
if ((status === "down" || status === "degraded") && !expected) {
const issueTitle = (config.issueTitle || "$PREFIX $SITE_NAME is $STATUS")
.replace(
"$PREFIX",
status === "down"
? config.issuePrefixStatusDown || "🛑"
: config.issuePrefixStatusDegraded || "⚠️"
)
.replace("$SITE_NAME", site.name)
.replace("$SITE_URL", site.url)
.replace("$SITE_METHOD", site.method || "GET")
.replace(
"$STATUS",
status === "down"
? status
: "experiencing degraded performance"
)
.replace("$RESPONSE_CODE", result.httpCode.toString())
.replace("$RESPONSE_TIME", responseTime)
.replace("$COMMIT", lastCommitSha.substr(0, 7))
.replace("$COMMIT_URL", `https://github.com/${owner}/${repo}/commit/${lastCommitSha}`);
const issueBody = (config.issueBody || `[[\`$COMMIT\`]($COMMIT_URL)] $SITE_NAME ($SITE_URL) is **$STATUS**.
- HTTP code: $RESPONSE_CODE
- Response time: $RESPONSE_TIME ms
`)
.replace(
"$PREFIX",
status === "down"
? config.issuePrefixStatusDown || "🛑"
: config.issuePrefixStatusDegraded || "⚠️"
)
.replace("$SITE_NAME", site.name)
.replace("$SITE_URL", site.url)
.replace("$SITE_METHOD", site.method || "GET")
.replace(
"$STATUS",
status === "down"
? status
: "experiencing degraded performance"
)
.replace("$RESPONSE_CODE", result.httpCode.toString())
.replace("$RESPONSE_TIME", responseTime)
.replace("$COMMIT", lastCommitSha.substr(0, 7))
.replace("$COMMIT_URL", `https://github.com/${owner}/${repo}/commit/${lastCommitSha}`);
if (!issues.data.length) {
const newIssue = await octokit.issues.create({
owner,
repo,
title:
status === "down"
? `🛑 ${site.name} is down`
: `⚠️ ${site.name} has degraded performance`,
body: `In [\`${lastCommitSha.substr(
0,
7
)}\`](https://github.com/${owner}/${repo}/commit/${lastCommitSha}), ${site.name} (${
site.url
}) ${status === "down" ? "was **down**" : "experienced **degraded performance**"}:
- HTTP code: ${result.httpCode}
- Response time: ${responseTime} ms
`,
labels: ["status", slug, ...(site.tags || [])],
title: issueTitle,
body: issueBody,
labels: ["status", slug, ...site.tags || []],
});
const assignees = [...(config.assignees || []), ...(site.assignees || [])];
await octokit.issues.addAssignees({
Expand Down