r/GoogleAppsScript • u/Rude_Union_7313 • May 06 '26
Question Syncing Google Apps Script with GitHub repo (auto-deploy on push?)
Hey y'all,
Is there a clean way to keep a Google Apps Script project in sync with a GitHub repo, so that on every push/commit the latest code is automatically deployed to Apps Script?
Ideally looking for something CI/CD-like (e.g. via GitHub Actions or similar), rather than manually pulling/pushing with clasp.
Curious how people are handling version control + deployment flows here. Any best practices or setups would be super helpful.
Thanks!
9
Upvotes
View all comments
Show parent comment
-1
u/Still_Dingo6159 May 07 '26
Hope this helps baby girl:
The function executes a POST request to the Apps Script API to trigger a deployment and retrieve the new version number. It calculates the previous two version numbers and utilizes Promise.all to concurrently fetch the code content for the active head and the two prior iterations from the API. The active head and immediate prior code are submitted via HTTP POST to the specified modeling endpoint, commanding it to notate variable alterations. A nested function verifies the character count of the model's returned notation and the historical code strings against a 49,000-character limit. If any string exceeds the limit, the function structures a multipart request body, uploads the raw text to Google Drive via the Drive API, and returns the generated web view link in place of the text. The function completes by executing an append POST request to the Sheets API targeting the dev_log sheet. This inherently resolves the last populated row and appends two continuous rows containing the version identifiers, the constrained notation output, and the constrained historical code strings or their respective Drive links. The routine returns a single object containing the deployment metadata, the raw model output, and the Sheets API append confirmation.