|
1 |
| -# apps-script-sync |
2 |
| -Sync files to script.google.com project |
| 1 | +# Google Apps Script Sync |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <img src="https://travis-ci.com/atom-tr/apps-script-sync.svg?branch=master"/> |
| 5 | + <img src="https://codecov.io/gh/atom-tr/apps-script-sync/branch/master/graph/badge.svg"/> |
| 6 | +</p> |
| 7 | + |
| 8 | +---- |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + <img src="https://img.shields.io/badge/language-python-blue?style"/> |
| 12 | + <img src="https://img.shields.io/github/license/atom-tr/apps-script-sync"/> |
| 13 | + <img src="https://img.shields.io/github/stars/atom-tr/apps-script-sync"/> |
| 14 | + <img src="https://img.shields.io/github/forks/atom-tr/apps-script-sync"/> |
| 15 | + <img src="https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99" alt="Star Badge"/> |
| 16 | +</p> |
| 17 | +<p align="center"> |
| 18 | + Are you tired of copy-pasting your code to script.google.com? <br> |
| 19 | + This tool will help you to sync your files to script.google.com project. |
| 20 | +</p> |
| 21 | + |
| 22 | +<p align="center"> |
| 23 | + <a href="https://github.com/atom-tr/apps-script-sync/issues">Report Bug</a> |
| 24 | + · |
| 25 | + <a href="https://github.com/atom-tr/apps-script-sync/issues">Request Feature</a> |
| 26 | + </p> |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +1. Create a new Google Apps Script project at <https://script.google.com/home>. |
| 31 | + - Get the project ID from the URL. It is the string between `/d/` and `/edit`. |
| 32 | +2. Follow the instructions at <https://developers.google.com/apps-script/api/quickstart/python> to: |
| 33 | + - Enable the Google Apps Script API for your project |
| 34 | + - Download the `credentials.json` file to your computer |
| 35 | + - Get the `token.json` file. |
| 36 | +3. You will need a GitHub token with `repo` scope. You can create one at <https://github.com/settings/tokens> |
| 37 | + > enabling the repo scope seems **DANGEROUS** |
| 38 | + but this is the only way to access the repository files and sync them to Google Script. |
| 39 | +4. Save secrets in your repository settings. |
| 40 | + - `GH_TOKEN`: GitHub token |
| 41 | + - `PROJECT_ID`: Google Script project ID |
| 42 | + - `CLIENT_ID`: Google app client ID |
| 43 | + - `CLIENT_SECRET`: Google app client secret |
| 44 | + - `REFRESH_TOKEN`: Google app refresh token |
| 45 | + |
| 46 | +## Workflow |
| 47 | + |
| 48 | +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: |
| 49 | + |
| 50 | +```yaml |
| 51 | +name: Sync to script.google |
| 52 | + |
| 53 | +on: [push] |
| 54 | + |
| 55 | +jobs: |
| 56 | + build: |
| 57 | + |
| 58 | + runs-on: ubuntu-latest |
| 59 | + strategy: |
| 60 | + matrix: |
| 61 | + python: ["3.11"] |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + - name: Setup Python |
| 66 | + uses: atom-tr/apps-script-sync@main |
| 67 | + with: |
| 68 | + # Github |
| 69 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 70 | + # Google Script |
| 71 | + PROJECT_ID: ${{ secrets.PROJECT_ID }} # Project ID, you can get it from the URL of your project |
| 72 | + PROJECT_PATH: # Project path, where the folder in repo will be synced to in Google Script, default is src |
| 73 | + # Google app |
| 74 | + # CLIENT_TYPE: installed |
| 75 | + CLIENT_ID: ${{ secrets.CLIENT_ID }} |
| 76 | + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} |
| 77 | + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} |
| 78 | +``` |
| 79 | +
|
| 80 | +When you push your code to the repository, the workflow will be triggered and it will sync your code to Google Script. |
0 commit comments