Giter Club home page Giter Club logo

action-google-drive's Introduction

Interact with Google Drive

This action uploads/downloads files to/from 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. Contributions to the roadmap are also welcome!

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

Roadmap

  • Support Windows / macOS runner (#9)
  • Embedded skicka metadata caching

action-google-drive's People

Contributors

pgaspar avatar satackey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

action-google-drive's Issues

Unable to get Skicka token

Google blocking skicka token generation access. How Can I overcome this. People are suggesting to use rclone

$ skicka ls
skicka: attempting to launch browser to authorize.
(Re-run skicka with the -no-browser-auth option to authorize directly.)


image

downloading a file by specifying the owner

problem

When I download a folder from google drive using this action, the file owner is root:root.

I am running a test program in CI, which place new files in a downloaded folder by this action.
However, when program try to place new files, I've got Permission Denied because the owner of the downloaded folder is root:root.

As a workaround, I have added a process to change the owner of the folder after downloading the folder by action.
An example is shown below.

name: Test
on: [push]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version: [3.9]
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v2

      - name: Download test data from Google Drive
        uses: satackey/action-google-drive@v1
        with:
          skicka-tokencache-json: ${{ secrets.SKICKA_TOKENCACHE_JSON }}
          download-from: /test-data
          download-to: ${{ github.workspace }}/tests/files/test-data/
          google-client-id: ${{ secrets.GOOGLE_CLIENT_ID }}
          google-client-secret: ${{ secrets.GOOGLE_CLIENT_SECRET }}

      - name: chown testdata dir (because satackey/action-google-drive@v1 downloads files as root owner)
        run: sudo chown -R runner:docker ${{ github.workspace }}/tests/files/test-data

suggestion

I would like to achieve simplicity in the description, preferably by specifying the user in the action.

For example, can we use the following option?

      - name: Download test data from Google Drive
        uses: satackey/action-google-drive@v1
        with:
          skicka-tokencache-json: ${{ secrets.SKICKA_TOKENCACHE_JSON }}
          download-from: /test-data
          download-to: ${{ github.workspace }}/tests/files/test-data/
          google-client-id: ${{ secrets.GOOGLE_CLIENT_ID }}
          google-client-secret: ${{ secrets.GOOGLE_CLIENT_SECRET }}
          user: runner # added
          group: docker # added

Cannot set up skicka for the first time

Hey, I've never used skicka before, and I'm following the steps described in the README. As per the troubleshooting procedure, after I get the "Sign in with Google temporarily disabled for this app" message, I'm trying to set up the Google Drive API client ID and secret, and set them in skicka.

I follow all the steps in the (translated) article. There is one difference, though:
Screenshot 2020-11-20 113850
when I'm asked for Application type, there is no "other" option, so I tried with Desktop app - the only one that does not ask for any additional info, apparently. After completing the steps though, after editing the .skicka_config and opening the URL that is given by skicka -no-browser-auth ls, I get the following error:
Screenshot 2020-11-20 115258
where I cancelled my gmail address.

Any ideas of what I might be missing?

Authorization error

The troubleshooting needs to be updated, I did everything as detailed in japanese, and got this:
image
It is one step further from the app being blocked, it still is not working as needed.

Cannot Set Up Skicka Token

It appears that the setup steps for generating a Skicka token no longer work as expected, as the client Oauth App has been deleted:

Screenshot 2023-11-29 at 11 09 17

The Skicka repo has been archived, as noted in #21 so it appears the project has been fully sunsetted.

Enable downloads

My workflow is that I want to edit content in Google Drive and that gets downloaded by the action and included in my build.

Specifically, I'm using Gatsby to generate static site content from markdown and I want to store the markdown in Google Drive and have it pulled automatically

Cannot locate files when uploading or downloading

Hi satackey, thank you for this amazing tool!

I'm almost ready to use it, but I'm still missing something. I can see that download-to and upload-from are, by default, the current directory. But what do you mean by that? What is this current directory from where I'm meant to upload the files?

Thank you again for your help!

[Security] Workflow push-prebuild.yml is using vulnerable action satackey/push-prebuilt-action

The workflow push-prebuild.yml is referencing action satackey/push-prebuilt-action using references v0.1. However this reference is missing the commit 0c027b66503f3857cb4e5cfb71633cc54dbd1ec6 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

This application is blocked

https://accounts.google.com/o/oauth2/auth?client_id=********-**********.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=********

This application is blocked This app tries to access sensitive information on your Google Account. To keep your account safe, Google blocks this access

Can I skip "Updating metadata cache"?

Thanks for providing this action!
I have lots of files in my Drive, Updating metadata cache took me more than one hour.
Can I skip this step? Or is there a way to cache the metadata in GitHub Actions?

Cannot sign in as app is not approved

I tried to log in with my user and google threw an error saying sign-in has been disabled for this app.

Sign in with Google temporarily disabled for this app
This app has not been verified yet by Google in order to use Google Sign In.

skicka: error with OAuth2 Authorization

First of all I want to thank you because of a really good guide to configure and get the credentials, the other actions assume that everyone knows it

Every time I try to run this action, it returns this message:

2020/05/02 00:46:05 created configuration file /github/home/.skicka.config.
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=

skicka: error with OAuth2 Authorization: oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error": "invalid_request",
  "error_description": "Missing required parameter: code"
} 
Enter verification code: 

I followed the steps as it show in the guide, but it seems I had to verify again the login in the github action terminal

Mkdir on Upload

Currently, the directory of upload-to property need to be created manually before the action runs to avoid the following error:

skicka: /path/to/upload: not found

It would be really convenient to create the target directory before the upload.

skicka mkdir -p /path/to/upload

By doing so, this action can be easily integrated with variables with simple expression. For example,

- name: Upload files to Google Drive
  uses: satackey/action-google-drive@v1
  with:
    skicka-tokencache-json: ${{ secrets.SKICKA_TOKENCACHE_JSON }}
    google-client-id: ${{ secrets.SKICKA_GOOGLE_CLIENT_ID }}
    google-client-secret: ${{ secrets.SKICKA_GOOGLE_CLIENT_SECRET }}
    upload-from: ./app/build/outputs/apk/
    upload-to: /my-app/apk/${{ steps.extract_version.outputs.appVersionName }}/

The expression, ${{ steps.extract_version.outputs.appVersionName }}, might be changed every time the action runs.

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.