Git Product home page Git Product logo

action-google-drive's Introduction

Upload to Google Drive

This action uploads the specified directory/files to Google Drive.

Example

Upload

- name: Upload to Google Drive
  uses: satackey/action-google-drive@v1
  with:
    skicka-tokencache-json: ${{ secrets.SKICKA_TOKENCACHE_JSON }}
    upload-from: ./
    upload-to: /path/to/upload

    # For those who set up Google Drive API client ID and secret themselves
    google-client-id: ${{ secrets.GOOGLE_CLIENT_ID }}
    google-client-secret: ${{ secrets.GOOGLE_CLIENT_SECRET }}

Donwload

- name: Download from Google Drive
  uses: satackey/action-google-drive@v1
  with:
    skicka-tokencache-json: ${{ secrets.SKICKA_TOKENCACHE_JSON }}
    download-from: /path/to/download
    download-to: ./

    # For those who set up Google Drive API client ID and secret themselves
    google-client-id: ${{ secrets.GOOGLE_CLIENT_ID }}
    google-client-secret: ${{ secrets.GOOGLE_CLIENT_SECRET }}

Get ready

This action uses skicka for uploading to Google Drive. You need to generate token and register it with GitHub secrets.

How to generate token

Users already using skicka

In your GitHub repository → Settings → Secrets, register by entering SKICKA_TOKENCACHE_JSON for name and the content of ~/.skicka.tokencache.json for value.

Users who have never used skicka

  1. Setup Docker and execute following command.

    docker run --rm -it --entrypoint "" satackey/skicka sh -c "skicka -no-browser-auth ls && cat /root/.skicka.tokencache.json"
  2. Access the URL showed in the output

  3. Grant access, paste code showed in the browser into the terminal.

  4. In your GitHub repository → Settings → Secrets, register by entering SKICKA_TOKENCACHE_JSON for name and the content of ~/.skicka.tokencache.json for value.

    {"ClientId":"xxx-xxxxx.apps.googleusercontent.com","access_token":"xxxx.xx-xxxxxxxxx","token_type":"Bearer","refresh_token":"x//xxxxxxx-xxxxxxx","expiry":"2020-01-03T06:11:01.3298117Z"}
Troubleshooting of sign in

As of Jan. 2, 2020, for the accounts that sign in to skicka for the first time, may have a problem of being displayed as Sign in with Google temporarily disabled for this app. The workaround is to set up the Google Drive API client ID and secret, and set them in skicka.

Follow this article (japanese only) to set up a client ID and secret. See translated by Google

Replace xxxx-your-google-client-id-xx.googleusercontent.com and xxx_yourGoogleClientSecret_xxxx, run the following command.

$ docker run -e GOOGLE_CLIENT_ID=xxxx-your-google-client-id-xx.googleusercontent.com -e GOOGLE_CLIENT_SECRET=xxx_yourGoogleClientSecret_xxxx --rm -it --entrypoint "ash" satackey/skicka

When the container starts, run the following command.

# sed -i -e "s/;clientid=YOUR_GOOGLE_APP_CLIENT_ID/clientid=$GOOGLE_CLIENT_ID/" ~/.skicka.config && sed -i -e "s/;clientsecret=YOUR_GOOGLE_APP_SECRET/clientsecret=$GOOGLE_CLIENT_SECRET/" ~/.skicka.config && skicka -no-browser-auth ls && cat /root/.skicka.tokencache.json

Return to step 2 and proceed, and similarly register your client ID and secret to the GitHub secret.

Inputs

  • skicka-tokencache-json Required
    The credentials of the account to upload, generated by skicka. (Contents of ~/.skicka.tokencache.json)

  • upload-from optional
    Upload source path. Default is the current directory.

  • upload-to Required for upload
    Upload destination path.

  • download-from Required for download
    Download source path.

  • download-to optional
    Download destination path. Default is the current directory.

  • google-client-id optional
    OAuth2.0 client ID of Google APIs when using skicka.
    Required for those who set up Google Drive API client ID and secret themselves. (Same for google-client-secret below)

  • google-client-secret optional
    OAuth2.0 Client Secret of Google APIs when using skicka.

  • remove-outdated optional, default: 'true'
    Whether to delete files that are not local but exist on Google Drive, either 'true' or 'false'

    Note: It is recommended to turn it off when performing operations involving large files, because it detects files that do not exist locally and downloads them.

Contribution

PRs are accepted.

If you are having trouble or feature request, post new issue.

action-google-drive's People

Contributors

satackey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.