diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml index db9cc01..25ed280 100644 --- a/.github/workflows/health-check.yml +++ b/.github/workflows/health-check.yml @@ -1,16 +1,16 @@ name: Scheduled Health Check -# Controls when the action will run. +# Controls when the action will run. on: 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/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 diff --git a/health-check.sh b/health-check.sh index 328b859..5d22b2f 100644 --- a/health-check.sh +++ b/health-check.sh @@ -1,23 +1,28 @@ +# 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.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 @@ -25,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 @@ -43,12 +46,20 @@ do sleep 5 done dateTime=$(date +'%Y-%m-%d %H:%M') - echo $dateTime, $result >> "logs/${key}_report.log" + if [[ $commit == true ]] + 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 == 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' + git add -A --force logs/ + git commit -am '[Automated] Update Health Check Logs' + git push +fi