Skip to content

Periodic API health check #452

Periodic API health check

Periodic API health check #452

Workflow file for this run

name: Periodic API health check
# This workflow is triggered on pushes to the repository.
on:
workflow_dispatch:
schedule:
# Runs at 0 minutes over the 4th hour on each day. Cron syntax
- cron: '0 5 * * *'
jobs:
health-test:
env:
STAGING_API_BASE_URL: https://statistics-api-staging.azurewebsites.net
MASTER_API_BASE_URL: https://statistics-api.azurewebsites.net
COURSE_ID: 360
MUNICIPALITY_ID: "0301"
DATA_MAX_AGE: 25200 # 7 hours
# This job runs on Linux
runs-on: ubuntu-latest
steps:
# GitHub repository checkout
- name: GitHub repository checkout
uses: actions/checkout@v4
- name: Check if data from API is less than DATA_MAX_AGE seconds old
run: |
if [ "$GITHUB_REF" = "refs/heads/stage" ]
then
chmod 700 $GITHUB_WORKSPACE/.github/health_test_src/do_health_test.py
API_BASE_URL=$STAGING_API_BASE_URL $GITHUB_WORKSPACE/.github/health_test_src/do_health_test.py
elif [ "$GITHUB_REF" = "refs/heads/master" ]
then
chmod 700 $GITHUB_WORKSPACE/.github/health_test_src/do_health_test.py
API_BASE_URL=$MASTER_API_BASE_URL $GITHUB_WORKSPACE/.github/health_test_src/do_health_test.py
fi