Sync People Sheet #92
This file contains hidden or 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: Sync People Sheet | |
| on: | |
| # Run every day at 06:00 UTC so new form submissions appear within 24 hours | |
| schedule: | |
| - cron: "0 6 * * *" | |
| # Allow manual trigger from the GitHub Actions tab | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-people: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: pip install pyyaml | |
| - name: Diagnose environment | |
| env: | |
| PEOPLE_SHEET_ID: ${{ secrets.PEOPLE_SHEET_ID || '1oW_QHLvJ1DGIFUP956T4W2nwn8xThw5t6QmaM_nxDjM' }} | |
| run: | | |
| echo "## Sync Diagnostics" >> $GITHUB_STEP_SUMMARY | |
| python --version >> $GITHUB_STEP_SUMMARY 2>&1 | |
| echo "PEOPLE_SHEET_ID set: $([[ -n "$PEOPLE_SHEET_ID" ]] && echo YES || echo NO)" >> $GITHUB_STEP_SUMMARY | |
| echo "PEOPLE_SHEET_ID length: ${#PEOPLE_SHEET_ID}" >> $GITHUB_STEP_SUMMARY | |
| python -c "import yaml; print('pyyaml OK')" >> $GITHUB_STEP_SUMMARY 2>&1 | |
| echo "Curl test (first 200 chars):" >> $GITHUB_STEP_SUMMARY | |
| curl -sL --max-time 15 \ | |
| "https://docs.google.com/spreadsheets/d/${PEOPLE_SHEET_ID}/export?format=csv&gid=0" \ | |
| | head -c 200 >> $GITHUB_STEP_SUMMARY 2>&1 || echo "curl failed" >> $GITHUB_STEP_SUMMARY | |
| - name: Sync people data from Google Sheet | |
| env: | |
| PEOPLE_SHEET_ID: ${{ secrets.PEOPLE_SHEET_ID || '1oW_QHLvJ1DGIFUP956T4W2nwn8xThw5t6QmaM_nxDjM' }} | |
| ALUMNI_SHEET_GID: ${{ secrets.ALUMNI_SHEET_GID || '1137118685' }} | |
| run: python -u scripts/sync_people_sheet.py 2>&1 | tee /tmp/sync_output.txt; exit ${PIPESTATUS[0]} | |
| - name: Upload sync log on failure | |
| if: failure() | |
| run: | | |
| echo "## Sync Script Output" >> $GITHUB_STEP_SUMMARY | |
| cat /tmp/sync_output.txt >> $GITHUB_STEP_SUMMARY 2>/dev/null || echo "(no output captured)" >> $GITHUB_STEP_SUMMARY | |
| - name: Commit changes when data or photos changed | |
| id: commit | |
| run: | | |
| if git diff --quiet && git diff --cached --quiet; then | |
| echo "No changes to commit." | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add _data/people.yml assets/img/team/ | |
| git commit -m "chore(people): sync lab member data from Google Sheet" | |
| # Pull and rebase before push to avoid race conditions | |
| git pull --rebase origin main || { | |
| echo "⚠️ Rebase conflict; aborting push." | |
| exit 1 | |
| } | |
| # Push with one retry on transient failure | |
| git push || git push | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| # Deploy is now triggered automatically on push to main; no manual dispatch needed. |