Very simplistic cli tool to push json data to a google sheet. The main purpose is to push artifact data from CI build steps to google sheets in order to analyze project quality over time.
- Create project on google cloud platform.
- Click Enable APIs and enable the Google Sheets API
- Go to Credentials, then click Create credentials, and select Service account key
- Choose New service account in the drop down. Give the account a name.
- For Role I selected Project -> Project -> Editor
- For Key type, choose JSON (the default) and download the file. This file contains a private key so be very careful with it
- Finally, edit the sharing permissions for the spreadsheet and give read/write access to the client_email address you can find in the JSON file
Download the phar
$ wget https://github.com/Trekels/php-sheet/releases/download/1.0.0/php-sheet.phar -O php-sheet
Make it executable and move to your bin folder.
$ sudo chmod a+x php-sheet.phar
$ sudo mv php-sheet /usr/local/bin/php-sheet
bin/phpsheet data ./path/to/file.json -c path/to/creds.json -s sheet_id
# if env vars are set :)
bin/sheet data ./path/to/file.json
--credentials | -c
can be omitted if the credentials json string is set as env var GOOGLE_SHEET_AUTH
.
--sheet | -s
can be omitted if env var GOOGLE_SHEET_ID
is set.