Are you tired of copy-pasting your code to script.google.com?
This tool will help you to sync your files to script.google.com project.
- Create a new Google Apps Script project at https://script.google.com/home.
- Get the project ID from the URL. It is the string between
/d/
and/edit
.
- Get the project ID from the URL. It is the string between
- Follow the instructions at https://developers.google.com/apps-script/api/quickstart/python to:
- Enable the Google Apps Script API for your project
- Download the
credentials.json
file to your computer - Get the
token.json
file.
- You will need a GitHub token with
repo
scope. You can create one at https://github.com/settings/tokensenabling the repo scope seems DANGEROUS but this is the only way to access the repository files and sync them to Google Script.
- Save secrets in your repository settings.
GH_TOKEN
: GitHub tokenPROJECT_ID
: Google Script project IDCLIENT_ID
: Google app client IDCLIENT_SECRET
: Google app client secretREFRESH_TOKEN
: Google app refresh token
First, you need to create a new repository for your project. Then, you need to create a new workflow file in .github/workflows
folder. You can use the following template:
name: Sync to script.google
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: atom-tr/apps-script-sync@main
with:
# Github
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# Google Script
PROJECT_ID: ${{ secrets.PROJECT_ID }} # Project ID, you can get it from the URL of your project
PROJECT_PATH: # Project path, where the folder in repo will be synced to in Google Script, default is src
# Google app
# CLIENT_TYPE: installed
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
When you push your code to the repository, the workflow will be triggered and it will sync your code to Google Script.