Skip to content

Commit 8c2fae5

Browse files
authored
feat: Add sync functionality
Initial version of the sync functionality
2 parents d06a6fd + c9669ba commit 8c2fae5

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
11
# salmon-sync
2+
3+
This is a Github Action that syncs a folder to a Google Cloud bucket using `rclone`.
4+
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.
5+
6+
## Parameters
7+
```
8+
inputs:
9+
source:
10+
required: true
11+
type: string
12+
description: 'The source directory to sync.'
13+
destination:
14+
required: true
15+
type: string
16+
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.'
17+
project_number:
18+
required: true
19+
type: string
20+
description: 'The Google Cloud project number.'
21+
bucket:
22+
required: true
23+
type: string
24+
description: 'The Google Cloud bucket to sync to.'
25+
credentials:
26+
required: true
27+
type: string
28+
description: 'The Google Cloud credentials. Should be base64 encoded.'
29+
```
30+
31+
## Example
32+
The action can be used as a step in a workflow
33+
Here is an example that syncs from the local path `temp/blog` to the blog section of the bucket.
34+
```
35+
- name: Sync to the blog
36+
uses: deephaven/salmon-sync@v1
37+
with:
38+
source: temp/blog
39+
destination: deephaven/deephaven.io/blog
40+
project_number: ${{ secrets.DOCS_GOOGLE_CLOUD_PROJECT_NUMBER}}
41+
bucket: ${{ vars.DOCS_GOOGLE_CLOUD_BUCKET }}
42+
credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }}
43+
```

action.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Sync Salmon Directory
2+
description: Syncs a directory to a Google Cloud bucket using rclone.
3+
author: 'deephaven'
4+
inputs:
5+
source:
6+
required: true
7+
type: string
8+
description: 'The source directory to sync.'
9+
destination:
10+
required: true
11+
type: string
12+
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.'
13+
project_number:
14+
required: true
15+
type: string
16+
description: 'The Google Cloud project number.'
17+
bucket:
18+
required: true
19+
type: string
20+
description: 'The Google Cloud bucket to sync to.'
21+
credentials:
22+
required: true
23+
type: string
24+
description: 'The Google Cloud credentials. Should be base64 encoded.'
25+
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Setup rclone
30+
uses: AnimMouse/setup-rclone@v1
31+
with:
32+
version: v1.68.1
33+
34+
- name: Decode credentials
35+
shell: bash
36+
run: |
37+
echo $RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS_ENCODED | base64 --decode > $HOME/credentials.json
38+
env:
39+
RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS_ENCODED: ${{ inputs.credentials }}
40+
41+
42+
- name: Sync source to destination
43+
shell: bash
44+
env:
45+
RCLONE_CONFIG_GCS_TYPE: "google cloud storage"
46+
RCLONE_GCS_SERVICE_ACCOUNT_FILE: $HOME/credentials.json
47+
RCLONE_GCS_PROJECT_NUMBER: ${{ inputs.project_number }}
48+
RCLONE_GCS_BUCKET_POLICY_ONLY: "true"
49+
run: rclone sync ${{ inputs.source }} gcs:${{ inputs.bucket }}/${{ inputs.destination }}

0 commit comments

Comments
 (0)