Update Johnson City Guide #28
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: Update Johnson City Guide | |
on: | |
schedule: | |
- cron: '0 6 * * *' # Run daily at 6:00 AM UTC (1:00 AM EST) | |
workflow_dispatch: # Allow manual triggering | |
jobs: | |
update-guide: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for proper versioning | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.9' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r config/requirements.txt | |
- name: Create backup | |
run: | | |
timestamp=$(date +%Y%m%d_%H%M%S) | |
mkdir -p data/backup_$timestamp | |
cp data/*.yml data/backup_$timestamp/ | |
- name: Fetch and update data | |
run: | | |
python scripts/update_guide.py | |
env: | |
YELP_API_KEY: ${{ secrets.YELP_API_KEY }} | |
EVENTBRITE_API_KEY: ${{ secrets.EVENTBRITE_API_KEY }} | |
NPS_API_KEY: ${{ secrets.NPS_API_KEY }} | |
OPENWEATHER_API_KEY: ${{ secrets.OPENWEATHER_API_KEY }} | |
ASTRONOMY_API_KEY: ${{ secrets.ASTRONOMY_API_KEY }} | |
GIT_USERNAME: "Jacob Booth" | |
GIT_EMAIL: "contact@jacobbooth.com" | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'Jacob Booth' | |
git config --global user.email 'contact@jacobbooth.com' | |
# Stage all relevant files | |
git add data/ README.md docs/CHANGELOG.md metrics/ | |
# Get current date for commit message | |
date=$(date +%Y-%m-%d) | |
# Only commit if there are changes | |
if ! git diff --staged --quiet; then | |
git commit -m "Daily Update: $date" -m "Automated update of Johnson City Guide data and documentation" | |
# Create and push tag | |
git tag -a "update-$date" -m "Daily update for $date" | |
git push origin main --tags | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload backup | |
uses: actions/upload-artifact@v3 | |
with: | |
name: data-backup | |
path: data/backup_* | |
retention-days: 7 |