Automatically sync images from Google Drive to GitHub with version control and automatic release notifications.
- 🔄 Automatically syncs images from a Google Drive folder to this GitHub repository
- 📅 Runs daily via GitHub Actions (customizable schedule)
- 🔔 Creates releases automatically when new images are added
- 📊 Tracks changes via Git commit history
- 🗂️ Preserves folder structure from your Google Drive
- GitHub Actions runs on a schedule (default: daily at 2 AM UTC)
- Connects to Google Drive using a service account
- Downloads any new or updated images
- Commits them to the repository
- Creates a GitHub Release to notify watchers
- Repeat!
- A Google account with Google Drive
- A GitHub account
- Images stored in a Google Drive folder
- Go to Google Cloud Console
- Click the project dropdown at the top
- Click "NEW PROJECT"
- Name it (e.g., "github-sync")
- Click "CREATE"
- In the search bar, type "Google Drive API"
- Click on "Google Drive API"
- Click "ENABLE"
- Go to "IAM & Admin" → "Service Accounts" (use the left sidebar or search)
- Click "+ CREATE SERVICE ACCOUNT"
- Fill in:
- Service account name:
github-sync(or whatever you prefer) - Service account ID: Auto-fills, leave it
- Service account name:
- Click "CREATE AND CONTINUE"
- Skip the optional steps (click "CONTINUE" then "DONE")
- Click on the service account you just created
- Go to the "KEYS" tab
- Click "ADD KEY" → "Create new key"
- Choose "JSON" format
- Click "CREATE"
- Save the downloaded JSON file - you'll need it later!
While still on this page, copy the service account email at the top.
It looks like: github-sync@your-project-name.iam.gserviceaccount.com
You'll need this in the next section!
- Go to Google Drive
- Navigate to the folder you want to sync
- Look at the URL in your browser:
https://drive.google.com/drive/folders/YOUR_FOLDER_ID_HERE - Copy everything after
/folders/- this is your folder ID
Example: If the URL is https://drive.google.com/drive/folders/143UQ42Vk1TBqQ7pT-5HTfUG8-RHr4bos
Then your folder ID is: 143UQ42Vk1TBqQ7pT-5HTfUG8-RHr4bos
- Right-click on the folder you want to sync
- Click "Share"
- In the "Add people and groups" field, paste your service account email
- (e.g.,
github-sync@your-project-name.iam.gserviceaccount.com)
- (e.g.,
- Set permission to "Viewer"
- Uncheck "Notify people"
- Click "Share"
Alternative: If you get an error, make the folder "Anyone with the link" instead:
- Click "Change" next to "Restricted"
- Select "Anyone with the link"
- Set to "Viewer"
- Go to GitHub
- Click "New repository"
- Name it (e.g., "image-collection")
- Choose Private or Public
- Click "Create repository"
Upload these files to your repository:
sync_drive_images.pyrequirements.txt.gitignore.github/workflows/sync-images.ymlREADME.md
You can drag and drop them via the GitHub web interface.
- Go to your repository's Settings
- Click "Secrets and variables" → "Actions"
- Click "New repository secret"
First Secret:
- Name:
GOOGLE_SERVICE_ACCOUNT_JSON - Value: Open the JSON file you downloaded earlier, copy ALL the contents, paste here
- Click "Add secret"
Second Secret:
- Name:
DRIVE_FOLDER_ID - Value: The folder ID you copied from the Drive URL
- Click "Add secret"
Important: The first sync should be done locally on your computer to avoid GitHub server timeouts when pushing hundreds of files at once.
git clone https://github.com/your-username/your-repo.git
cd your-repo# macOS/Linux
pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib
# Windows
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlibOn macOS/Linux:
export DRIVE_FOLDER_ID="your-folder-id-here"
export GOOGLE_SERVICE_ACCOUNT_JSON='paste-entire-json-contents-here'On Windows (PowerShell):
$env:DRIVE_FOLDER_ID="your-folder-id-here"
$env:GOOGLE_SERVICE_ACCOUNT_JSON='paste-entire-json-contents-here'# macOS/Linux
python3 sync_drive_images.py
# Windows
python sync_drive_images.pyThis will download all images to the images/ folder.
git add images/ manifest.json .gitattributes
git commit -m "Initial sync: Add all images from Google Drive"
git pushIf the push fails with HTTP 500 errors (too many files), push in batches:
# Add and commit 100 files at a time
git add $(git ls-files --others images/ | head -100)
git commit -m "Initial sync batch 1"
git push
# Repeat for more batches
git add $(git ls-files --others images/ | head -100)
git commit -m "Initial sync batch 2"
git pushAfter the initial setup, GitHub Actions will automatically:
- Run every day at 2 AM UTC
- Check Google Drive for new/updated images
- Download and commit any changes
- Create a release if new images were added
You don't need to do anything - it runs automatically!
To trigger a sync manually:
- Go to the Actions tab in your repository
- Click "Sync Google Drive Images"
- Click "Run workflow"
- Click the green "Run workflow" button
To change when automatic syncs run:
- Edit
.github/workflows/sync-images.yml - Find the line:
cron: '0 2 * * *' - Change it to your preferred schedule:
# Every 6 hours
- cron: '0 */6 * * *'
# Every Monday at 9 AM
- cron: '0 9 * * 1'
# Twice daily (2 AM and 2 PM)
- cron: '0 2,14 * * *'- Go to Settings → Collaborators
- Click "Add people"
- Enter their GitHub username or email
- Choose permission level:
- Read: Can view and clone (recommended for viewers)
- Write: Can push changes
- Admin: Full control
After you invite them, they can:
git clone https://github.com/your-username/your-repo.git
cd your-repoTo pull new updates:
git pullEvery time new images are added, the workflow automatically creates a GitHub Release with:
- A timestamp
- Number of new images added
- Number of updated images
- Link to the commit with changes
Option 1: Watch Releases Only (Recommended)
- Click "Watch" at the top of the repository
- Select "Custom"
- Check "Releases" only
- Click "Apply"
Now you'll get a notification whenever new images are added!
Option 2: Use RSS Feed
Subscribe to the releases RSS feed in any RSS reader:
https://github.com/your-username/your-repo/releases.atom
Option 3: Email Notifications
GitHub will email you about releases if you have "Watch: Releases" enabled.
After syncing, your repository will look like this:
your-repo/
├── .github/
│ └── workflows/
│ └── sync-images.yml # GitHub Actions workflow
├── images/ # All synced images (matches Drive structure)
│ ├── Folder 1/
│ │ ├── image1.png
│ │ └── image2.jpg
│ └── Folder 2/
│ └── image3.png
├── sync_drive_images.py # Sync script
├── requirements.txt # Python dependencies
├── manifest.json # Tracks synced files (auto-generated)
├── .gitignore # Ignores sensitive files
└── README.md # This file
The images/ folder structure exactly mirrors your Google Drive folder structure.
Problem: The folder ID is wrong or the service account doesn't have access.
Solutions:
- Double-check your
DRIVE_FOLDER_ID- make sure you copied the complete folder ID from the URL - Verify the folder is shared with your service account email
- Try making the folder "Anyone with the link" instead
Problem: Too many files being pushed at once.
Solution: For the first sync, always do it locally and push in batches (see Part 4.5 above).
Problem: The service account doesn't have access to the folder.
Solution: Make sure you shared the folder with the exact service account email from Google Cloud.
Problem: GitHub Actions might be disabled.
Solutions:
- Go to Settings → Actions → General
- Make sure Actions are enabled
- Check that the workflow file is in
.github/workflows/(notgithub/workflows/)
Problem: Push succeeded but images aren't visible.
Solutions:
- Hard refresh your browser (Ctrl+Shift+R or Cmd+Shift+R)
- Check the commits - click on the latest commit to see what files were added
- Look for the
images/folder in your repository
- File size limit: 100 MB per file
- Repository size: Soft limit ~1 GB, hard limit 5 GB
- For very large collections, consider using Git LFS
- ✅ Service account JSON is stored securely in GitHub Secrets
- ✅ Never commit the JSON file to your repository
- ✅ The
.gitignorefile prevents accidental commits
- Google Drive API: Free (up to 20,000 requests/day)
- GitHub Actions:
- Public repos: Unlimited minutes
- Private repos: 2,000 minutes/month free
If you encounter issues:
- Check the Actions tab for error logs
- Verify your secrets are set correctly
- Make sure the folder is shared with the service account
- Double-check the folder ID is complete
After setup is complete:
- ✅ Your images sync automatically every day
- ✅ Collaborators get notified via releases
- ✅ Full version history via Git commits
- ✅ Just add images to Google Drive and forget about it!
Enjoy your automated image collection! 🎉