# [Repost] How to automate Google Apps Script deployments and workflows with GitHub Actions

This is a copy of a post I've written on AppsScriptPulse - [How to automate Google Apps Script deployments with GitHub Actions](https://pulse.appsscript.info/p/2022/06/how-to-automate-google-apps-script-deployments-with-github-actions/)

Managing code particularly in container bound projects can be a real headache for Apps Script developers. The Script REST API has made this a lot easier both is terms of managing scripts but also opening up options for different development environments, including local development using [`clasp`](https://developers.google.com/apps-script/guides/clasp) and your preferred IDE.

In terms of version control there are a number of solutions Apps Script developers can now consider. The [Google Apps Script GitHub Assistant Chrome Extension](https://chrome.google.com/webstore/detail/google-apps-script-github/lfjcgcmkmjjlieihflfhjopckgpelofo?hl=en) is a popular option as it extends the existing online Script Editor with integration with GitHub and several other Source Code Management services (GitHub Enterprise/Bitbucket/GitLab).

For developers interested in developing projects locally there is perhaps even more choice. One solution we’ve featured a couple of times in Pulse is the use of GitHub Actions:

> GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.
> 
> <https://github.com/features/actions>

The latest example for using GitHub Actions comes from Goran Kukurin ([gorankukurin.com](https://gorankukurin.com/)). Goran has shared a setup for developing code in Google Sheets with development and production versions. As well as using GitHub Actions to automatically push code to the correct Google Sheet version a shell script is used to modify the custom menu name as a useful reminder so you can see what version you are testing:

![](https://hawksey.info/wp-content/uploads/2022/06/Automate-Google-Apps-Script-deployments-with-GitHub-Actions-1-e1654871407143-1024x397.png)You can visit Goran’s post (linked below) for an example repo and instructions on how to setup. If you are using a UNIX based operating system it should be straightforward. If like me you are on a Windows machine there are some minor tweaks and possibly big `node-gyp` headaches to overcome, which I’ve highlighted below (in Goran’s website post some commands with `--` are displaying as `-` – the [GitHub repo](https://github.com/gkukurin/automate_apps_script_deployment) and [Medium version are ok).](https://medium.com/@gkukurin/how-to-automate-google-apps-script-deployments-with-github-actions-d28d7fb8b879)

**Windows Tips**

You are better using PowerShell rather than CMD so you don’t have to modify things like `$HOME` to `%HOMEPATH%`.

If you’ve not already got `node-gyp` installed the setup that worked for me on Windows 11 was:

- Node 14.19.3
- Python 3.10
- Visual Studio Build Tools 2017

After installing with `npm install -g node-gyp` there are [Windows specific setup instructions](https://github.com/nodejs/node-gyp#on-windows) (don’t forget `npm config set msvs_version 2017`).

After creating the spreadsheets I needed to specify the directory by including `src` (I think this is a nit) e.g.:

`mv src\.clasp.json .clasp-prd.json`

To encrypt your clasp credentials you might need to install [install GnuPG](https://www.gnupg.org/download/index.html).

If you are running the setup build tasks in VS Code and get:

`'.' is not recognized as an internal or external command`

I solved this by configuring `npm` to use `bash.exe`, some other options are give in [this SO answer](https://stackoverflow.com/a/55303370/1027723).

**Final thought**

There is a lot more you could do with GitHub Actions like pushing to multiple production spreadsheets and much more. This post from Goran Kukurin is a great insight to what is possible and we look forward to seeing where other Apps Script devs go with it.

Source: *[How to automate Google Apps Script deployments with GitHub Actions](https://gorankukurin.com/google-workspace/how-to-automate-google-apps-script-deployments-with-github-actions/) (also [published on Medium](https://medium.com/@gkukurin/how-to-automate-google-apps-script-deployments-with-github-actions-d28d7fb8b879))*