Skip to content

Cron - Predictions #9982

Cron - Predictions

Cron - Predictions #9982

Workflow file for this run

name: Cron - Predictions
on:
workflow_dispatch:
schedule:
- cron: '*/15 13-20 * * 1-5' # every 15 minutes from 9 AM to 4 PM (Monday to Friday) EST
- cron: '0 * * * *' # every hour otherwise to refresh
jobs:
scripts:
runs-on: ubuntu-latest
outputs:
exitcode: ${{ steps.read-emails.outputs.exitcode }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip' # caching pip dependencies
- run: |
echo "::group::pip install -r scripts/requirements.txt"
pip install -r scripts/requirements.txt
echo "::endgroup::"
- name: Read Emails
id: read-emails
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TOKEN_JSON: ${{ secrets.TOKEN_JSON }}
run: |
set +e
echo "${TOKEN_JSON}" > token.json
python scripts/read_emails.py
echo "exitcode=$?" >> $GITHUB_OUTPUT
- name: Fail if Unexpected Error Code
env:
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
run: |
if [[ ${{ steps.read-emails.outputs.exitcode }} != "0" && ${{ steps.read-emails.outputs.exitcode }} != "7" ]]; then
echo "Exit code was: ${{ steps.read-emails.outputs.exitcode }}"
exit 1
else
python scripts/update_gha_secret.py
echo "Secret expires $(jq .expiry token.json)"
rm token.json
fi
- name: Check for any missing business days
if: ${{ steps.read-emails.outputs.exitcode == 0 }}
run: python scripts/missing_business_days.py
- name: Predict using Word Vector Model
if: ${{ steps.read-emails.outputs.exitcode == 0 }}
run: python scripts/predict/predict.py
- name: Predict using Embedding Model
if: ${{ steps.read-emails.outputs.exitcode == 0 }}
run: python scripts/predict/predict_embeddings.py
- name: Update Front End Data
if: ${{ steps.read-emails.outputs.exitcode == 0 }}
run: ./scripts/update_front_end.sh
- name: Update Data
if: ${{ steps.read-emails.outputs.exitcode == 0 }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add data/data.db view/src/contexts/predictions/data/
git commit -m "Updating Prediction Data for $(date)"
git push