Skip to content
arrow-up

GitHub Action

Google Cloud Storage Bucket Sync (GCP,GCS)

1.4 Latest version

Google Cloud Storage Bucket Sync (GCP,GCS)

arrow-up

Google Cloud Storage Bucket Sync (GCP,GCS)

Sync a Github repository with a Google Cloud Storage (GCS) bucket

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Google Cloud Storage Bucket Sync (GCP,GCS)

uses: patrickwyler/[email protected]

Learn more about this action in patrickwyler/gcs-bucket-sync-action

Choose a version

GCS Bucket Sync Action

This action helps by easily syncing a Github repository with a Google Cloud Storage bucket. It is very generic and can be used for different purposes. I used it for uploading my static website.

Features

  • Sync files/directories from your repository to your bucket
  • Delete files/directories from your bucket which where removed in your repository
  • Exclude certain files from being synced with the bucket

Requirements

  • An existing empty* bucket
  • A service account with access to the bucket
  • The service account key (json format)

*If you want to sync to an existing bucket, make sure that your repository includes the whole content of it, otherwise you will lose data!

Inputs

  • secrets Your Google service account credentials as json. (Required)
  • bucket Name of the target bucket. (Required)
  • sync_dir_from Repository directory path to sync, for example, my_folder/to_sync. It is empty by default.
  • sync_dir_to Bucket directory path to sync to, for example, my_folder/to_sync. It is empty by default.
  • exclude Regex for excluding files/dirs. (gsutil rsync doc)

Example

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Sync
        uses: patrickwyler/[email protected]
        with:
          secrets: ${{ secrets.google_service_account_credentials }}
          bucket: 'patrickwyler.com'
          exclude: '.*\.md$|\.gitignore$|\.git/.*$|\.github/.*$'

Diagram

Diagram

Tags

GCP, Google Cloud Platform, GCS, Google Cloud Storage, Bucket, Sync, Syncing, Uploading, Upload