Make Flu Forecast Submission #6
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: Make Flu Forecast Submission | |
on: | |
schedule: | |
# Every Wednesday at 6pm CET (17:00 UTC) | |
- cron: '0 17 * * 3' | |
workflow_dispatch: # Allow manual triggering | |
jobs: | |
submit-forecast: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests pandas numpy | |
- name: Create required directories | |
run: | | |
mkdir -p flu/submissions | |
- name: Run flu forecasting script | |
run: python flu/run-flu-forecasts.py | |
env: | |
PYTHONPATH: ${{ github.workspace }} | |
- name: Fork and clone target repository | |
run: | | |
# Install GitHub CLI | |
gh auth login --with-token <<< "${{ secrets.PRIVATE_ACCESS_TOKEN }}" | |
# Fork the repository (if not already forked) | |
gh repo fork cdcepi/FluSight-forecast-hub --clone=true | |
- name: Copy forecast files | |
run: | | |
# Create target directory if it doesn't exist | |
mkdir -p FluSight-forecast-hub/model-output/metac-cp | |
# Copy new forecasts | |
cp -r flu/submissions/* FluSight-forecast-hub/model-output/metac-cp/ | |
- name: Create Pull Request | |
run: | | |
cd FluSight-forecast-hub | |
# Setup git config | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
# Create a new branch | |
BRANCH_NAME="flu-forecast-update-$(date +%Y%m%d)" | |
git checkout -b $BRANCH_NAME | |
# Add and commit changes | |
git add model-output/metac-cp/ | |
# Only commit if there are changes | |
if git diff --staged --quiet; then | |
echo "No changes to commit" | |
exit 0 | |
else | |
git commit -m "Update flu forecasts $(date +%Y-%m-%d)" | |
# Set the remote URL with authentication token | |
git remote set-url origin "https://${{ secrets.PRIVATE_ACCESS_TOKEN }}@github.com/${{ github.actor }}/FluSight-forecast-hub.git" | |
# Push to fork | |
git push origin $BRANCH_NAME | |
# Create PR | |
gh pr create \ | |
--title "Update flu forecasts $(date +%Y-%m-%d)" \ | |
--body "Automated flu forecast submission from Metaculus" \ | |
--repo cdcepi/FluSight-forecast-hub \ | |
--base main | |
fi | |
env: | |
PRIVATE_ACCESS_TOKEN: ${{ secrets.PRIVATE_ACCESS_TOKEN }} |