-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of the sync functionality
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,43 @@ | ||
# salmon-sync | ||
|
||
This is a Github Action that syncs a folder to a Google Cloud bucket using `rclone`. | ||
This action is only meant to work for Deephaven's documentation. It could be used in a more general purpose way to sync a folder into any Google cloud bucket (with the proper credentials), but that is subject to change and may break in any version. | ||
|
||
## Parameters | ||
``` | ||
inputs: | ||
source: | ||
required: true | ||
type: string | ||
description: 'The source directory to sync.' | ||
destination: | ||
required: true | ||
type: string | ||
description: 'The destination directory to sync. Relative to the bucket. It is recommended to use the GitHub repo path (such as deephaven/salmon-sync) as the minimum base to prevent collisions.' | ||
project_number: | ||
required: true | ||
type: string | ||
description: 'The Google Cloud project number.' | ||
bucket: | ||
required: true | ||
type: string | ||
description: 'The Google Cloud bucket to sync to.' | ||
credentials: | ||
required: true | ||
type: string | ||
description: 'The Google Cloud credentials. Should be base64 encoded.' | ||
``` | ||
|
||
## Example | ||
The action can be used as a step in a workflow | ||
Here is an example that syncs from the local path `temp/blog` to the blog section of the bucket. | ||
``` | ||
- name: Sync to the blog | ||
uses: deephaven/salmon-sync@v1 | ||
with: | ||
source: temp/blog | ||
destination: deephaven/deephaven.io/blog | ||
project_number: ${{ secrets.DOCS_GOOGLE_CLOUD_PROJECT_NUMBER}} | ||
bucket: ${{ vars.DOCS_GOOGLE_CLOUD_BUCKET }} | ||
credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Sync Salmon Directory | ||
description: Syncs a directory to a Google Cloud bucket using rclone. | ||
author: 'deephaven' | ||
inputs: | ||
source: | ||
required: true | ||
type: string | ||
description: 'The source directory to sync.' | ||
destination: | ||
required: true | ||
type: string | ||
description: 'The destination directory to sync. Relative to the bucket. It is recommended to use the GitHub repo path (such as deephaven/salmon-sync) as the minimum base to prevent collisions.' | ||
project_number: | ||
required: true | ||
type: string | ||
description: 'The Google Cloud project number.' | ||
bucket: | ||
required: true | ||
type: string | ||
description: 'The Google Cloud bucket to sync to.' | ||
credentials: | ||
required: true | ||
type: string | ||
description: 'The Google Cloud credentials. Should be base64 encoded.' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup rclone | ||
uses: AnimMouse/setup-rclone@v1 | ||
with: | ||
version: v1.68.1 | ||
|
||
- name: Decode credentials | ||
shell: bash | ||
run: | | ||
echo $RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS_ENCODED | base64 --decode > $HOME/credentials.json | ||
env: | ||
RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS_ENCODED: ${{ inputs.credentials }} | ||
|
||
|
||
- name: Sync source to destination | ||
shell: bash | ||
env: | ||
RCLONE_CONFIG_GCS_TYPE: "google cloud storage" | ||
RCLONE_GCS_SERVICE_ACCOUNT_FILE: $HOME/credentials.json | ||
RCLONE_GCS_PROJECT_NUMBER: ${{ inputs.project_number }} | ||
RCLONE_GCS_BUCKET_POLICY_ONLY: "true" | ||
run: rclone sync ${{ inputs.source }} gcs:${{ inputs.bucket }}/${{ inputs.destination }} |