Skip to content

savi2w/gcp-storage-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Action to GCP Storage Bucket

This simple action uses the gsutil tool to sync a directory (either from your repository or generated during your workflow) with a remote GCP Storage bucket

Usage

workflow.yml

Place in a .yml file such as this one in your .github/workflows folder. Refer to the documentation on workflow YAML syntax here.

Mostly gsutil rsync flags are optional to allow for maximum customizability and must be provided by you via args:

Example

  • -d mirror source and destination. See.
name: gcp-storage-sync

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: savi2w/gcp-storage-sync@main
        with:
          args: -d
        env:
          GCP_SERVICE_ACCOUNT_KEY_FILE: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY_FILE }}
          GCP_STORAGE_BUCKET: ${{ secrets.GCP_STORAGE_BUCKET }}
          SOURCE_DIR: "public"

Configuration

The following settings must be passed as environment variables as shown in the example. Sensitive information, especially GCP_SERVICE_ACCOUNT_KEY_FILE, should be set as encrypted secrets — otherwise, they'll be public to anyone browsing your repository's source code and CI logs

Key Value Suggested Type Required Default
GCP_SERVICE_ACCOUNT_KEY_FILE Your JSON GCP service account key file. More info here Secret ENV Yes N/A
GCP_STORAGE_BUCKET Your GCP Storage bucket name For example, my-project Secret ENV Yes N/A
SOURCE_DIR The local directory (or file) you wish to sync/upload to GCP Storage. For example, public ENV Yes N/A
DEST_DIR The directory inside of the GCP Storage bucket you wish to sync/upload to. For example, my_project/assets. Defaults to the root of the bucket ENV No / (root of bucket)

License

This project is distributed under the MIT license