Skip to content

Fetch data and update dashboard #217

Fetch data and update dashboard

Fetch data and update dashboard #217

Workflow file for this run

# Workflow for updating dashboard with FRED data
name: Fetch data and update dashboard
on:
schedule:
- cron: '00 13 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: pip install pandas==2.3.0 plotly==6.2.0 fredapi==0.5.2 python-dotenv==1.1.1
- name: Run graph generation script
env:
FRED_API_KEY: ${{ secrets.FRED_API_KEY }}
run: python content/dashboard/dashboard.py
- name: Commit and push updated charts and data
id: commit_and_push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add static/dashboard/*.html static/dashboard/*.csv
if ! git diff --staged --quiet; then
echo "Changes detected in generated files. Committing..."
git commit -m "Update dashboard with newly released data"
git push
echo "committed=true" >> "$GITHUB_ENV" # Set an environment variable for the next step
else
echo "No changes detected in generated files. Nothing to commit."
echo "committed=false" >> "$GITHUB_ENV" # Set an environment variable for the next step
fi
- name: Trigger hugo.yml if committed
# This step will only run if the 'committed' environment variable is 'true'
if: ${{ env.committed == 'true' }}
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.DASHBOARD_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"data-committed-for-deploy", "client_payload": {"committed": "true"}}'