Only works with a Google Service Account!
To make a Google Service Account, go to the Credentials Dashboard and press CREATE CREDENTIALS
, then click on Service Account
. After creating the SA, go back to the Credentials Dashboard, click on the SA you just created, click on the KEYS
tabs. Then click on ADD KEY
, Create New Key
and select json
.
-
Encode the credentials.
cat credentials.json | base64
-
Create a new Github secret called
credentials
and copy the output of the previous command into this secret. -
Use this secret as your credentials input in your workflow.
-
Create a new Github secret called
credentials
paste the contents of the credentials file you just downloaded in it. -
Use this secret as your credentials input in your workflow.
-
Set the
encoded
input tofalse
in your workflow.
You will also need to share the drive with the service account. To do this, just share the folder like you would normally with a friend, except you share it with the Service Account email address.
Additionally you need to enable the Google Drive API for your GCP project. Do this by going here and pressing ENABLE
.
In this example we stored the folderId and credentials as action secrets. This is highly recommended as leaking your credentials key will allow anyone to use your service account.
# .github/workflows/main.yml
name: Main
on:
push:
branches:
- 'master'
- 'main'
- '!test'
jobs:
gdrive-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Archive files
run: |
sudo apt-get update
sudo apt-get install zip
zip -r archive.zip *
- name: Upload to gdrive
uses: mathisve/gdrive-upload-action@main
with:
filename: archive.zip
name: documentation.zip
folderId: ${{ secrets.folderId }}
credentials: ${{ secrets.credentials }}
encoded: false
Required: YES
The name of the file you want to upload.
Required: NO
The name you want the file to have in Google Drive. If this input is not provided, it will use the filename
.
Required: YES
The ID of the folder you want to upload to.
Required: YES
A string with the GSA credentials.
This string should be base64 encoded. If it is not, set the encoded
input to false
.
Required: NO
Whether or not the credentials string is base64 encoded. Defaults to true
.
Required: NO
If you want to overwrite all existing files in the drive folder that match the given name
, with the current file content. Defaults to false
For contribution user guide see CONTRIBUTING.md