Skip to content

Commit

Permalink
Implement automated update system with enhanced security
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-booth committed Jan 17, 2025
1 parent feac6a3 commit 9aca034
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 17 deletions.
52 changes: 42 additions & 10 deletions .github/workflows/update-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Update Johnson City Guide

on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight
- cron: '0 6 * * *' # Run daily at 6:00 AM UTC (1:00 AM EST)
workflow_dispatch: # Allow manual triggering

jobs:
Expand All @@ -12,29 +12,61 @@ jobs:
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 requests
pip install yamllint
pip install -r 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 update_guide.py
yamllint data/
env:
YELP_API_KEY: ${{ secrets.YELP_API_KEY }}
EVENTBRITE_API_KEY: ${{ secrets.EVENTBRITE_API_KEY }}
NPS_API_KEY: ${{ secrets.NPS_API_KEY }}
GIT_USERNAME: "Jacob Booth"
GIT_EMAIL: "contact@jacobbooth.com"

- name: Commit and push changes
run: |
git config --global user.name 'Cline'
git config --global user.email 'cline@example.com'
git add data/
git diff --quiet || git commit -m "Update guide with new data"
git push
git config --global user.name 'Jacob Booth'
git config --global user.email 'contact@jacobbooth.com'
# Stage all relevant files
git add data/ README.md 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 }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload backup
uses: actions/upload-artifact@v3
with:
name: data-backup
path: data/backup_*
retention-days: 7
63 changes: 60 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
node_modules/
# Hide update system components
update_guide.py
/src/
/logs/
/metrics/
requirements.txt
.env
*.pyc
api/.env
api/index.js
.github/workflows/

# Python
__pycache__/
.DS_Store
*.py[cod]
*$py.class
*.so
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Keep data files visible
!data/*.yml
!README.md
!CHANGELOG.md
!LICENSE.md
!CODE_OF_CONDUCT.md
!CONTRIBUTING.md
!DISCOVERIES.md

# Hide all .github workflows except public ones
.github/workflows/*
!.github/workflows/ci.yml
24 changes: 24 additions & 0 deletions logs/update.log
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,27 @@ Changes:
2025-01-17 01:45:22,957 - JohnsonCityGuide - INFO - Update cycle completed successfully
2025-01-17 01:45:22,957 - JohnsonCityGuide - INFO - Update process completed in 0:00:04.761324
2025-01-17 01:45:22,958 - JohnsonCityGuide - INFO - Metrics saved to metrics\daily_stats.json
2025-01-17 01:45:58,703 - JohnsonCityGuide - INFO - Starting guide update process
2025-01-17 01:45:58,703 - JohnsonCityGuide - INFO - Environment validation successful
2025-01-17 01:45:58,707 - JohnsonCityGuide - INFO - Created backup in data\backup_20250117_014558
2025-01-17 01:45:59,678 - JohnsonCityGuide - INFO - API Call to /restaurants: Success (Duration: 0.88s)
2025-01-17 01:45:59,686 - JohnsonCityGuide - INFO - Updated 20 entries in restaurants
2025-01-17 01:46:00,332 - JohnsonCityGuide - INFO - API Call to /shops: Success (Duration: 0.65s)
2025-01-17 01:46:00,336 - JohnsonCityGuide - INFO - Updated 20 entries in shops
2025-01-17 01:46:00,678 - JohnsonCityGuide - INFO - API Call to /events: Success (Duration: 0.34s)
2025-01-17 01:46:00,678 - JohnsonCityGuide - WARNING - No data received for events
2025-01-17 01:46:01,693 - JohnsonCityGuide - INFO - API Call to /parks: Success (Duration: 1.01s)
2025-01-17 01:46:01,695 - JohnsonCityGuide - INFO - Updated 10 entries in parks
2025-01-17 01:46:01,696 - JohnsonCityGuide - INFO - Updated README.md timestamp
2025-01-17 01:46:01,696 - JohnsonCityGuide - INFO - Updated CHANGELOG.md
2025-01-17 01:46:01,849 - JohnsonCityGuide - INFO - Changes committed: Daily Update: 2025-01-17 01:46:01

Changes:
- Updated 20 entries in restaurants
- Updated 20 entries in shops
- Updated 10 entries in parks
2025-01-17 01:46:01,885 - JohnsonCityGuide - INFO - Created tag: update-20250117
2025-01-17 01:46:05,265 - JohnsonCityGuide - INFO - Changes pushed to remote repository
2025-01-17 01:46:05,266 - JohnsonCityGuide - INFO - Update cycle completed successfully
2025-01-17 01:46:05,266 - JohnsonCityGuide - INFO - Update process completed in 0:00:06.562816
2025-01-17 01:46:05,267 - JohnsonCityGuide - INFO - Metrics saved to metrics\daily_stats.json
8 changes: 4 additions & 4 deletions metrics/daily_stats.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"duration": "0:00:04.761324",
"duration": "0:00:06.562816",
"changes": {
"restaurants": 20,
"shops": 20,
"events": 0,
"parks": 0
"parks": 10
},
"error_count": 0,
"warning_count": 5,
"timestamp": "2025-01-17T01:45:22.958244"
"warning_count": 1,
"timestamp": "2025-01-17T01:46:05.266758"
}

0 comments on commit 9aca034

Please sign in to comment.