atom-tr / apps-script-sync

Sync files to script.google.com project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Apps Script Sync


Star Badge

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.

Report Bug · Request Feature

Prerequisites

  1. 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.
  2. 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.
  3. You will need a GitHub token with repo scope. You can create one at https://github.com/settings/tokens

    enabling the repo scope seems DANGEROUS but this is the only way to access the repository files and sync them to Google Script.

  4. Save secrets in your repository settings.
    • GH_TOKEN: GitHub token
    • PROJECT_ID: Google Script project ID
    • CLIENT_ID: Google app client ID
    • CLIENT_SECRET: Google app client secret
    • REFRESH_TOKEN: Google app refresh token

Workflow

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.

About

Sync files to script.google.com project

License:MIT License


Languages

Language:Python 95.8%Language:Dockerfile 4.2%