Periodic API health check #443
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
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 |