Drawing Folder Watcher
Daily/hourly digest of new and revised drawings in a Google Drive folder.
Sibling workflow
This is the GC / Construction drawing watcher. For shops where drawings arrive as Gmail attachments (machine shops, fabricators, suppliers), use drawing-rev-watcher instead — that one extracts part numbers from PDF title blocks via AI and tracks revisions against a part-master Sheet.
Use this one when drawings live in a shared Drive folder (architectural sets, MEP coordination drawings, structural calcs).
What it does
- Lists files in a Drive folder (your project's drawings shared folder).
- Compares to the last-known state (stored in a Google Sheet so reruns are idempotent).
- Emits a digest: new files added since last check, files whose modifiedTime changed (revisions).
- Updates the state Sheet for next run.
- Sends the digest to the PM.
Pattern note
This workflow uses a single runtimeenv task that invokes gog directly for the four Google operations (read Drive listing, read state, clear state, append state). The runtimeenv receives the Google Workspace credential via credentialNames, so gog is automatically authenticated.
Why not strict hybrid (separate google_workspace tasks per op)? Because state-keeping has two reads + two writes; splitting into 5+ tasks would force passing JSON state between tasks via template substitution, which is fragile under shell quoting. One runtimeenv task with credentialNames is cleaner here.
Setup
1. Drive folder
Any shared Drive or My Drive folder. Note the folder ID from the URL. Grant your service account Viewer access.
2. State Sheet
Create a Sheet (anywhere; the service account needs Editor on it). Add a tab DrawingState with this header row:
| file_id | file_name | modified_time | last_seen_at |
|---|---|---|---|
The workflow rewrites rows 2+ on every run. Don't manually edit.
3. Credential + contact + placeholders
Replace these in workflow.yaml:
- <<GOOGLE_WORKSPACE_CREDENTIAL>> — your credential name (Sheets + Drive scope)
- <<DRIVE_FOLDER_ID>> — the drawing folder ID
- <<STATE_SHEET_ID>> — the state Sheet ID
- <<PM_PUBLISHER>> — your PM contact's user name
4. Schedule
Suggested: hourly during work hours, or daily 6:00 AM. Frequent polling = faster alerts; less frequent = less Drive API quota use.
First run
The first run treats every file in the folder as "new" because the state Sheet is empty. Expect a long digest on day one. After that, only changes show up.
Limitations
- Max 500 files per folder (configurable in the
--maxflag in the script). - Recursion into subfolders is not enabled by default. If you have one folder per project, set up one workflow per project. If you have nested folders, modify the
gog drive lscall. - Drive's
modifiedTimereflects file metadata changes, not just content. Editing a file's name will look like a "revision" — usually fine, occasionally a false alarm.