-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (112 loc) · 4.28 KB
/
nightly-update.yml
File metadata and controls
131 lines (112 loc) · 4.28 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Nightly Workshop Data Update and Site Rebuild
on:
schedule:
# Run daily at 7:30 AM UTC (12:30 AM PST) - 26 minutes after Google Sheets update
- cron: '30 7 * * *'
workflow_dispatch: # Allow manual triggering
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "nightly-update"
cancel-in-progress: false
jobs:
update-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
# Setup Python for data fetching
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Step 1: Update workshop catalog from Google Sheets (fetch definitions first)
- name: Fetch workshop catalog from Google Sheets
env:
GOOGLE_WORKSHOPS_SHEET_ID: ${{ secrets.GOOGLE_WORKSHOPS_SHEET_ID }}
GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
run: |
echo "Fetching workshop catalog..."
python scripts/fetch_workshop_catalog.py
echo "Workshop catalog fetch completed"
# Step 2: Update workshop data from Google Sheets (fetch scheduled sessions)
- name: Fetch workshop data from Google Sheets
env:
GOOGLE_SHEET_ID: ${{ secrets.GOOGLE_SHEET_ID }}
GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
GOOGLE_WORKSHOPS_SHEET_ID: ${{ secrets.GOOGLE_WORKSHOPS_SHEET_ID }}
run: |
echo "Fetching workshop data..."
python scripts/fetch_google_sheets.py
echo "Workshop data fetch completed"
# Step 3: Generate workshop pages for new workshops
- name: Generate workshop pages for new workshops
run: |
echo "Generating workshop pages..."
python scripts/generate_workshop_pages.py
echo "Workshop page generation completed"
# Step 4: Commit data changes
- name: Commit workshop data changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add _data/upcoming_workshops.json _data/workshops.yml data/upcoming_workshops.json workshop/
if git diff --staged --quiet; then
echo "No workshop data changes to commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
git commit -m "Nightly update: workshop data and catalog $(date -u '+%Y-%m-%d %H:%M UTC')"
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Workshop data changes committed"
fi
id: commit_data
# Step 5: Setup Ruby and Jekyll (only if we have changes or it's a scheduled run)
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Install Jekyll dependencies
run: bundle install
# Step 6: Setup GitHub Pages
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
# Step 7: Build Jekyll site
- name: Build with Jekyll
run: |
echo "Building Jekyll site..."
bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
echo "Jekyll build completed"
env:
JEKYLL_ENV: production
# Step 8: Upload and deploy to GitHub Pages
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Step 9: Push data changes to repository (after successful deployment)
- name: Push changes to repository
if: steps.commit_data.outputs.has_changes == 'true'
run: |
echo "Pushing changes to repository..."
git push
echo "Changes pushed successfully"
# Step 10: Summary
- name: Workflow Summary
run: |
echo "🎉 Nightly update completed successfully!"
echo "📊 Data updated: ${{ steps.commit_data.outputs.has_changes }}"
echo "🚀 Site deployed to: ${{ steps.deployment.outputs.page_url }}"
echo "⏰ Completed at: $(date -u '+%Y-%m-%d %H:%M UTC')"