forked from mpa139/allanlab
-
Notifications
You must be signed in to change notification settings - Fork 5
60 lines (49 loc) · 1.67 KB
/
sync-team-data.yml
File metadata and controls
60 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Sync Team Data from Google Sheets
on:
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
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 from Google Sheets
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
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 sync script
python sync_team_service_account.py
- name: Check for changes
id: verify-changed-files
run: |
git diff --quiet _data/*.yml || 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
git commit -m "Update team data from Google Sheets"
git push