Skip to content

texas-mcallen-mission/deploy-google-app-script-action-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Github -> AppsScript Bridge

Send your code directly from Github to Google's AppsScript environment.

Why does this exist?

This is a project that got started because we use Google AppsScript a lot- we've built a big project on top of it. Google's internal editor has some problems- it doesn't support TypeScript (which is practically a necessity for a project as large as ours), it's nowhere near as powerful as vsCode is, and it doesn't have a nice dark mode. To get around these shortcomings, we adapted somebody else's work and made this thing. It's built off of CLASP, which lets you use your favorite desktop editor to do things, but instead of running CLASP from your computer, you do it in the cloud! (Isn't that cool?)

Part of the reason that we're using this instead of something that uses Google Cloud Platform is that our org doesn't use GCP, but we do have access to AppsScript.

There's a minimum viable project demo available here: deploy-tester

Getting Started

Copy new-reusable.yml into your own project, change the branch name to whatever branch you're working on.

Using the Default Workflow

  1. Create a personal access token with read and write access to secrets. Create a secret named REPO_ACCESS_TOKEN and store it there.
  2. Install Clasp locally, and log in.
  3. Go to your home directory, and find .clasprc.json. Copy the contents of the file.
  4. Create a secret named CLASPRC_JSON, and paste all the contents from step 3 in here.
  5. Create a secret named SCRIPT_ID and put your script id in it.
    • *you can technically replace ${{ secrets.SCRIPT_ID }} with your script id, but this isn't recommended as it could be less secure.
  6. After that's all saved, you should be able to run your workflow in your repository and see a file named aaa-git-info show up in your appsscript editor.

Inputs

Input Value Description Required Default Value
CLASP_TOKEN_VALUE Clasp login token value. yes
CLASP_TOKEN_NAME clasprc token name - used to update the access token and keep it alive.1 no CLASPRC_JSON
REPO_ACCESS_TOKEN Personal access token that has secrets modifying scopes.2 yes
USES_ORG_SECRET Updates org secret instead of repo secret if set to true no FALSE
ORG_VISIBILITY Only used if USES_ORG_SECRET is true, for changing what repositories have access to the value. no all
SCRIPT_ID Script id for script to be modified yes
PARENT_ID Parent id - if you have a project connected to a Google Sheet, for instance, put the id of that sheet here. Works with Docs, Slides, & Sheets at the very least. no
DEPLOYMENT_ID For larger deployments and version control inside of AppsScript. no
CONFIG_DATA JSON config data to pass into git-info.js3 no
  1. This is mostly useful to give a more meaningful name if you have a ton of secrets in your project.

  2. For organizations, needs R/W access to repo and org secrets.

  3. JSON format, but don't encapsulate it. Should look something like this:

    config_value: "string",
    config_submodule: {
        demoThingy1: false
    },
    config_array: ["words",true,{key:"value"}]

Demo Workflows

uses: texas-mcallen-mission/deploy-google-app-script-action-typescript/@v3.0.1
Clasp token stored on repo
with:
  CLASP_TOKEN_VALUE: ${{ secrets.CLASPRC_JSON }}
  CLASP_TOKEN_NAME: 'CLASPRC_JSON'
  REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
  SCRIPT_ID: ${{ secrets.SCRIPT_ID }}
Clasp token stored in org
with:
  CLASP_TOKEN_VALUE: ${{ secrets.CLASPRC_JSON }}
  CLASP_TOKEN_NAME: 'CLASPRC_JSON'
  REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
  USES_ORG_SECRET: true
  ORG_VISIBILITY: all # optional, default all.
  SCRIPT_ID: ${{ secrets.SCRIPT_ID }}

Attribution

This is built off of deploy-google-app-script-action written by ericanastas but has some significant changes made to it to make it easier to get started with, more powerful, and more error-resistant.

About

Gets things from Github to the Google AppScript environment automatically. Also compiles TypeScript files!

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published