Skip to content

Sync Data from Google Sheets and PubMed #121

Sync Data from Google Sheets and PubMed

Sync Data from Google Sheets and PubMed #121

name: Sync Data from Google Sheets and PubMed
on:
schedule:
# Run daily at 2 AM Eastern Time (6 AM UTC during EDT, 7 AM UTC during EST)
- cron: '0 6 * * *'
workflow_dispatch: # Allow manual trigger
jobs:
sync-team-data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install google-auth google-auth-oauthlib google-auth-httplib2
pip install google-api-python-client PyYAML
- name: Sync Team Data from Google Sheets
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
TEAM_SPREADSHEET_ID: ${{ secrets.TEAM_SPREADSHEET_ID }}
run: |
# Debug: Check if secret is set
if [ -z "$SERVICE_ACCOUNT_KEY" ]; then
echo "Error: SERVICE_ACCOUNT_KEY secret is not set!"
exit 1
fi
# Create service account key file from secret
echo "$SERVICE_ACCOUNT_KEY" > service-account-key.json
# Debug: Check file was created
ls -la service-account-key.json
# Run the team sync script
python sync_team_service_account.py
- name: Sync Quotes from Google Sheets
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
run: |
# Run the quotes sync script (uses hardcoded spreadsheet ID)
python sync_quotes_from_sheets.py
- name: Sync News from Google Sheets
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
NEWS_SPREADSHEET_ID: ${{ secrets.NEWS_SPREADSHEET_ID }}
run: |
# Update the news sync script with the spreadsheet ID
if [ -n "$NEWS_SPREADSHEET_ID" ]; then
# Create a temporary copy with the spreadsheet ID
sed "s/YOUR_NEWS_SPREADSHEET_ID_HERE/$NEWS_SPREADSHEET_ID/g" sync_news_from_sheets.py > sync_news_temp.py
# Run the news sync script
python sync_news_temp.py
# Clean up temporary file
rm sync_news_temp.py
else
echo "NEWS_SPREADSHEET_ID not set, skipping news sync"
fi
- name: Sync Publications from PubMed
run: |
# Run the PubMed scraping script
python scrape_pubmed_auto.py
- name: Check for changes
id: verify-changed-files
run: |
git diff --quiet _data/*.yml _pages/quotes.md || echo "changed=true" >> $GITHUB_OUTPUT
- name: Commit and push if changed
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add _data/*.yml _pages/quotes.md
git commit -m "Update data from Google Sheets and PubMed"
git push