Getting your scripts to Github is not the easiest thing in world. Nowadays people mainly do it manually, which is fine for small scripts, but when you have many with lots of library dependencies, it can be a nightmare to keep up to date. In Using Drive SDK I described why you might want to use the SDK JSON API rather than the built in Apps Script Drive Class. We'll us that, along with the Github API. Don't forget you'll need Oauth2 for drive set up as described in Oauth2 step by step - apps script authentication for the Drive JSON API and you'll also need it for GitHub as described in Step by Step - Apps Script Oauth2 authentication with Github. For how to do this with VBA, see Integrate VBA with Github Note: There have been some changes to this as of Nov 2018 - namely
These are explained in this more recent post. What does GasGit doGets a group of apps script projects and their library dependencies to GitHub with the GitHub API, using Drive as a local repository. A selection of my Apps Script projects (including this one), can be found on my github account, and have been put there using GasGit in just a few minutes. What's in the repoHere's what this repo looks like when automatically created and committed. You can find the repository for GasGit here. The readme fileThis is committed if there isn't one in the repo, otherwise it leaves it alone. The idea is that you use the initial skeleton to build on. If you want the skeleton re-instated, just delete your readme from the repo. It doesn't say much and looks like this. This is created in the doLibraries() stage and committed to guthub in the doGit() stage if there's not already a README in the repository. The dependency reportThis describes what's in the repo, and gives you all you need to be able to clone the project. All the libraries and library dependencies are shown along with their key. If the source of the library is available ( you own it and you committed it with GasGit as part of the same scope as the project), it will also be here. From this data you can decide whether to use the libraries or clone. This is created/modified in the doLibraries() stage and committed to guthub in the doGit() stage The info.jsonThis is used to create all the documentation above, and to control execution of GasGit. It is updated at each stage and committed to guthub in the doGit() stage. Note that the info.json file will always be slightly different to the one on github, since it records when it was committed after the commit completed. Take a look directly on github, it's a little big to reproduce below. The scripts folderThis is the source for all your scripts in your project and looks like this (see previous note - these files are now at the top level. The libraries folderIf available then all the sources for each dependency needed by this project and its libraries. Each folder name matches a library, and contains the source for that library. Note that every library that is referenced for which sources are available are committed here - including libraries that are referenced by other libraries and so on. This list matched the dependency list in the dependencies.md report. The WorkflowHere's the workflow (once you've done the one off setup work for oauth2 and tweaked the settings for your drive folder layout). Since all this happens on Drive, it's client independent - you can run it on a Mac, Linux , Windows a Chromebook (even a mobile device i suppose), and you don't even need to have git installed since it uses the github API and operates directly on Drive files. Step 0 - setup
Step 1 - doExtraction()
Step 2 - doLibraries()
Step 3 - doGit()
LibrariesUsing this approach, users of your repository can choose to use the provided library keys, or to use the cloned library source that is kept refreshed in the repository. Note that library versions in use for a particular project are noted in the dependencies.md documentation, but the library source is always the latest. You can find the repository for GasGit here. I'll be adding to the technical writeup over time. For now it's a little thin. For more on drive SDK see Using Drive SDK
|
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Drive SDK and GitHub >