From aba66a43d2af0a6b756d1dda26690e6f95683bd7 Mon Sep 17 00:00:00 2001 From: Vijaye Raji Date: Wed, 16 Jun 2021 13:52:11 -0700 Subject: [PATCH 1/5] Stop pushing status updates in the origin repository --- .github/workflows/health-check.yml | 15 +++++++++------ health-check.sh | 31 ++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml index db9cc01..1e575cb 100644 --- a/.github/workflows/health-check.yml +++ b/.github/workflows/health-check.yml @@ -1,16 +1,19 @@ name: Scheduled Health Check -# Controls when the action will run. +# Controls when the action will run. on: + pull_request: + branches: + - main schedule: - - cron: "30 * * * *" + - cron: "30 * * * *" 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 ./health-check.sh + - uses: actions/checkout@v2 + - name: Run Shell Script + id: shell_script_run + run: bash ./health-check.sh diff --git a/health-check.sh b/health-check.sh index 328b859..a5c6b77 100644 --- a/health-check.sh +++ b/health-check.sh @@ -1,3 +1,13 @@ +# 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=() @@ -12,7 +22,6 @@ do URLSARRAY+=(${TOKENS[1]}) done < "$urlsConfig" - echo "***********************" echo $KEYSARRAY echo $URLSARRAY @@ -43,12 +52,18 @@ do sleep 5 done dateTime=$(date +'%Y-%m-%d %H:%M') - echo $dateTime, $result >> "logs/${key}_report.log" + if [[ $commit ]] then + echo $dateTime, $result >> "logs/${key}_report.log" + else + echo $dateTime, $result + fi done -git config --global user.name 'Vijaye Raji' -git config --global user.email 'vijaye@statsig.com' -git add -A --force logs/ -git commit -am 'Status logs - automated' -git push - +if [[ $commit ]] then + # Let's make Vijaye the most productive person on GitHub. + git config --global user.name 'Vijaye Raji' + git config --global user.email 'vijaye@statsig.com' + git add -A --force logs/ + git commit -am '[Automated] Update Health Check Logs' + git push +fi From eea6d50e00cad71a9bc4fc28f7e55f0cdf205e75 Mon Sep 17 00:00:00 2001 From: Vijaye Raji Date: Wed, 16 Jun 2021 13:54:07 -0700 Subject: [PATCH 2/5] bash syntax fix --- health-check.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/health-check.sh b/health-check.sh index a5c6b77..a792e90 100644 --- a/health-check.sh +++ b/health-check.sh @@ -52,14 +52,16 @@ do sleep 5 done dateTime=$(date +'%Y-%m-%d %H:%M') - if [[ $commit ]] then + if [[ $commit == true ]] + then echo $dateTime, $result >> "logs/${key}_report.log" else echo $dateTime, $result fi done -if [[ $commit ]] then +if [[ $commit == true ]] +then # Let's make Vijaye the most productive person on GitHub. git config --global user.name 'Vijaye Raji' git config --global user.email 'vijaye@statsig.com' From f6a5aa2f08af61b21afe2eee9136cbaae172819a Mon Sep 17 00:00:00 2001 From: Vijaye Raji Date: Wed, 16 Jun 2021 14:06:31 -0700 Subject: [PATCH 3/5] Prettify preview runs --- health-check.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/health-check.sh b/health-check.sh index a792e90..5d22b2f 100644 --- a/health-check.sh +++ b/health-check.sh @@ -3,7 +3,7 @@ # later upstream merges messy for anyone who forked us. commit=true origin=$(git remote get-url origin) -if [[ $origin == *statsig-io/statuspage ]] +if [[ $origin == *statsig-io/statuspage* ]] then commit=false fi @@ -12,21 +12,17 @@ KEYSARRAY=() URLSARRAY=() urlsConfig="./urls.cfg" +echo "Reading $urlsConfig" while read -r line do - echo "$line" + echo " $line" IFS='=' read -ra TOKENS <<< "$line" - echo $TOKENS - KEYSARRAY+=(${TOKENS[0]}) URLSARRAY+=(${TOKENS[1]}) done < "$urlsConfig" echo "***********************" -echo $KEYSARRAY -echo $URLSARRAY -echo ${#KEYSARRAY[@]} -echo "***********************" +echo "Starting health checks with ${#KEYSARRAY[@]} configs:" mkdir -p logs @@ -34,9 +30,7 @@ for (( index=0; index < ${#KEYSARRAY[@]}; index++)) do key="${KEYSARRAY[index]}" url="${URLSARRAY[index]}" - - echo $key - echo $url + echo " $key=$url" for i in 1 2 3 4; do @@ -56,7 +50,7 @@ do then echo $dateTime, $result >> "logs/${key}_report.log" else - echo $dateTime, $result + echo " $dateTime, $result" fi done From ff5e27bfe9071e284ef30c454fd511f115cbcb1f Mon Sep 17 00:00:00 2001 From: Vijaye Raji Date: Wed, 16 Jun 2021 14:07:14 -0700 Subject: [PATCH 4/5] Remove test entries in GH workflow --- .github/workflows/health-check.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml index 1e575cb..25ed280 100644 --- a/.github/workflows/health-check.yml +++ b/.github/workflows/health-check.yml @@ -2,9 +2,6 @@ name: Scheduled Health Check # Controls when the action will run. on: - pull_request: - branches: - - main schedule: - cron: "30 * * * *" From 1d8bbca557f382e3ecf29924c6892f56228a04a2 Mon Sep 17 00:00:00 2001 From: Rodrigo Roim Date: Wed, 16 Jun 2021 14:13:27 -0700 Subject: [PATCH 5/5] Add status badge to README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e7b278..b025d51 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ +[![Health Check](../../actions/workflows/health-check.yml/badge.svg)](../../actions/workflows/health-check.yml) + # Statsig's Open-Source Status Page We tried various Status Pages out there, and built this as a fun little hobby project to make status pages as simple as possible. ## Demo -* https://status.statsig.com -* Live view of this repo: https://statsig-io.github.io/statuspage/ +- https://status.statsig.com ## Setup instructions