Run daily TM cron projects #176
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: Run daily TM cron projects | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Run every day at 0 UTC | |
workflow_dispatch: | |
inputs: | |
raw_data_api_url: | |
description: "Enter Raw data url" | |
default: "https://api-prod.raw-data.hotosm.org/v1" | |
required: false | |
raw_data_api_auth_token: | |
description: "Raw data api authentication token" | |
required: false | |
projectHours: | |
description: "Number of hours to fetch active projects (1-24)" | |
required: false | |
default: "24" # Default value as a string | |
tasking_manager_api_key: | |
description: "Enter the TASKING MANAGER API KEY (leave blank if not applicable)" | |
required: false | |
jobs: | |
Run-Scheduled-Exports: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Determine project hours | |
id: project_hours | |
env: | |
MANUAL_INPUT: ${{ github.event.inputs.projectHours }} | |
run: | | |
if [ "$GITHUB_EVENT_NAME" = "schedule" ] || [ -z "$MANUAL_INPUT" ] || ! [[ "$MANUAL_INPUT" =~ ^[0-9]+$ ]] || [ "$MANUAL_INPUT" -le 0 ] || [ "$MANUAL_INPUT" -gt 24 ]; then | |
echo "Using default value: 24" | |
echo "::set-output name=value::24" | |
else | |
echo "Using manual input: $MANUAL_INPUT" | |
echo "::set-output name=value::$MANUAL_INPUT" | |
fi | |
- name: Shoot daily projects | |
run: python tm_extractor.py --fetch-active-projects ${{ steps.project_hours.outputs.value }} | |
env: | |
RAW_DATA_API_BASE_URL: ${{ github.event.inputs.raw_data_api_url || 'https://api-prod.raw-data.hotosm.org/v1' }} | |
RAWDATA_API_AUTH_TOKEN: ${{ github.event.inputs.raw_data_api_auth_token || secrets.RAWDATA_API_AUTH_TOKEN }} | |
TASKING_MANAGER_API_KEY: ${{ github.event.inputs.tasking_manager_api_key || 'None' }} |