Github action for downloading google-drive files or folder using Drives: list API
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: raeperd/raeperd/google-drive-download-action@v1.0
with:
clientId: ${{ secrets.CLIENT_ID }}
clientSecret: ${{ secrets.CLIENT_SECRET }}
redirectUri: ${{ secrets.REDIRECT_URI }}
credential_json: ${{ secrets.CREDENTIAL_JSON }}
q: "'1U-2NgagKTnqkIZrML52A2SsD9HDDeDN7' in parents"
path: "./"
clientId
(required)- Client id of oauth2 client application
clientSecret
(required)- Client secret of oauth2 client application
redirectUri
(required)- Redirect uri of oauth2 client application
credential_json
(required)- credential.json value with refresh_token with scope
https://www.googleapis.com/auth/drive.readonly
- credential.json value with refresh_token with scope
q
(required)- Query string to search for files and folders
path
(optional)- Path to download files default to working directory
- Default to
./
Before we start, we need Google Drive Application Project and credential.json
- Create a Google Cloud project
- Setup Google API Oauth2 prerequisites
- After creating your credentials, download the
client_secret.json
file from the API Console.
- After creating your credentials, download the
- Enable the Google Drive API
- Create
credential.json
using Node.js quickstart | Google Drive API - Or you can create
credential.json
using ts-node - npm- Clone this repository, and install dependencies
- Move your
client_secret.json
file into repository directory with nameoauth.keys.json
-
ts-node write-credential.ts
❗❗ NEVER INCLUDE YOUR CLIENT SECRET (oauth.keys.json
and credential.json
) IN VERSION CONTROL ❗❗
To run this action, we need 4 repository secret parameter
- clientId
- clientSecret
- redirectUri
- credential_json
- First 3 parameters can be obtained by
client_secret.json
(oroauth.keys.json
) - credential_json is contents of file
credential.json
created by you- This value is parsed by action, using
JSON.parse()
function. - Check out /src/input.ts for more detail
- This value is parsed by action, using
Use debug.ts file in this repo
- Define constants
CLIENT_ID
,CLIENT_SECRET
,REDIRECT_URI
,CREDENTIAL_JSON
- Define constants
query
insidemain()
function - Run
ts-node ./debug.ts
and checkout results
❗❗ **NEVER INCLUDE YOUR CHANGES OF debug.ts
IN VERSION CONTROL ❗❗