-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mahatab
committed
Aug 7, 2022
1 parent
308bbe7
commit d3e0157
Showing
12 changed files
with
2,109 additions
and
1,988 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,16 @@ | ||
name: Scheduled Health Check | ||
|
||
# Controls when the action will run. | ||
on: | ||
schedule: | ||
- cron: "5 * * * *" | ||
|
||
jobs: | ||
health_check_job: | ||
runs-on: ubuntu-latest | ||
name: Check all sites | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run Shell Script | ||
id: shell_script_run | ||
run: bash ./scripts/health-check.sh |
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,27 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
function useRequest(url: string) { | ||
const [data, setData] = useState([]); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState(); | ||
|
||
useEffect(() => { | ||
const loadData = async () => { | ||
setIsLoading(true); | ||
try { | ||
let response = await fetch(url); | ||
let data = await response.json(); | ||
setData(data); | ||
} catch (e: any) { | ||
setError(e); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
loadData(); | ||
}, [url]); | ||
|
||
return [data, isLoading, error]; | ||
} | ||
|
||
export default useRequest; |
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 @@ | ||
google: https://google.com |
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 @@ | ||
import { useState, useEffect } from "react"; | ||
import Incidents from '../types/Incidents'; | ||
|
||
function useIncidents(url: string) { | ||
const [data, setData] = useState<Incidents[]>([]); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState(); | ||
|
||
useEffect(() => { | ||
const loadData = async () => { | ||
setIsLoading(true); | ||
try { | ||
let response = await fetch(url); | ||
let data = await response.json(); | ||
setData(data as Incidents[]); | ||
} catch (e: any) { | ||
setError(e); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
loadData(); | ||
}, [url]); | ||
|
||
return [data, isLoading, error]; | ||
} | ||
|
||
export default useIncidents; |
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,31 @@ | ||
import useIncidents from './hooks/useIncidents' | ||
import type { NextPage } from 'next' | ||
import Incidents from './types/Incidents'; | ||
|
||
const IncidentsSection: NextPage = () => { | ||
const [data, isPostsLoading] = useIncidents( | ||
"https://api.github.com/repos/aws/aws-cdk/issues" | ||
); | ||
return ( | ||
<div> | ||
<h1>Incidents </h1> | ||
{ | ||
isPostsLoading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<ul> | ||
{ | ||
(data as Incidents[]).map(incident => ( | ||
<li key={incident.id}> | ||
<h2>{incident.title}</h2> | ||
</li> | ||
)) | ||
} | ||
</ul> | ||
) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
export default IncidentsSection |
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,11 @@ | ||
interface Incidents { | ||
id: number; | ||
title: string; | ||
state: string; | ||
created_at: string; | ||
updated_at: string; | ||
closed_at: string; | ||
body: string; | ||
} | ||
|
||
export default Incidents; |
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,13 @@ | ||
import { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
export default function Document() { | ||
return ( | ||
<Html className="light"> | ||
<Head /> | ||
<body className="dark:bg-gray-800"> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import type { NextPage } from 'next' | ||
import Head from 'next/head' | ||
import Image from 'next/image' | ||
import styles from '../styles/Home.module.css' | ||
import useRequest from '../common/hooks/useRequest' | ||
import IncidentsSection from "../page-components/incidents" | ||
|
||
const Home: NextPage = () => { | ||
const [data, isPostsLoading, error] = useRequest( | ||
"https://api.github.com/repos/aws/aws-cdk/issues" | ||
); | ||
return ( | ||
<h1 className="text-3xl font-bold underline"> | ||
Hello world! | ||
</h1> | ||
<div className="bg-white dark:bg-slate-800 rounded-lg px-6 py-8 ring-1 ring-slate-900/5 shadow-xl"> | ||
<IncidentsSection /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Home | ||
export default Home; |
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,67 @@ | ||
# In the original repository we'll just print the result of status checks, | ||
# without committing. This avoids generating several commits that would make | ||
# later upstream merges messy for anyone who forked us. | ||
commit=true | ||
origin=$(git remote get-url origin) | ||
if [[ $origin == *statsig-io/statuspage* ]] | ||
then | ||
commit=false | ||
fi | ||
|
||
KEYSARRAY=() | ||
URLSARRAY=() | ||
|
||
urlsConfig="./urls.yml" | ||
echo "Reading $urlsConfig" | ||
while read -r line | ||
do | ||
echo " $line" | ||
IFS='=' read -ra TOKENS <<< "$line" | ||
KEYSARRAY+=(${TOKENS[0]}) | ||
URLSARRAY+=(${TOKENS[1]}) | ||
done < "$urlsConfig" | ||
|
||
echo "***********************" | ||
echo "Starting health checks with ${#KEYSARRAY[@]} configs:" | ||
|
||
mkdir -p logs | ||
|
||
for (( index=0; index < ${#KEYSARRAY[@]}; index++)) | ||
do | ||
key="${KEYSARRAY[index]}" | ||
url="${URLSARRAY[index]}" | ||
echo " $key=$url" | ||
|
||
for i in 1 2 3 4; | ||
do | ||
response=$(curl --write-out '%{http_code}' --silent --output /dev/null $url) | ||
if [ "$response" -eq 200 ] || [ "$response" -eq 202 ] || [ "$response" -eq 301 ] || [ "$response" -eq 302 ] || [ "$response" -eq 307 ]; then | ||
result="success" | ||
else | ||
result="failed" | ||
fi | ||
if [ "$result" = "success" ]; then | ||
break | ||
fi | ||
sleep 5 | ||
done | ||
dateTime=$(date +'%Y-%m-%d %H:%M') | ||
if [[ $commit == true ]] | ||
then | ||
echo $dateTime, $result >> "status/${key}_report.log" | ||
# By default we keep 2000 last log entries. Feel free to modify this to meet your needs. | ||
echo "$(tail -2000 status/${key}_report.log)" > "status/${key}_report.log" | ||
else | ||
echo " $dateTime, $result" | ||
fi | ||
done | ||
|
||
if [[ $commit == true ]] | ||
then | ||
# Let's make Vijaye the most productive person on GitHub. | ||
git config --global user.name 'mehatab' | ||
git config --global user.email '[email protected]' | ||
git add -A --force status/ | ||
git commit -am '[Automated] Update Health Check Logs' | ||
git push | ||
fi |
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
Oops, something went wrong.