Skip to content

Commit 75cd2a3

Browse files
authored
Change to AWS upload
2 parents 2fc9451 + 583e331 commit 75cd2a3

File tree

2 files changed

+42
-55
lines changed

2 files changed

+42
-55
lines changed

README.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# salmon-sync
22

3-
This is a Github Action that syncs a folder to a Google Cloud bucket using `rclone` and then send an authenticated request to the doc site to invalidate the cache for the doc version.
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.
3+
This is a Github Action that syncs a folder to a S3 bucket using `rclone`.
4+
This action is only meant to work for Deephaven's documentation.
55

66
## Parameters
77

@@ -15,22 +15,20 @@ inputs:
1515
required: true
1616
type: string
1717
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."
18-
bucket:
18+
aws-role:
1919
required: true
2020
type: string
21-
description: "The Google Cloud bucket to sync to."
22-
credentials:
23-
required: true
24-
type: string
25-
description: "The Google Cloud credentials. Should be base64 encoded."
26-
cache-bust-token:
27-
required: true
28-
type: string
29-
description: "The cache-bust token"
30-
docs-url:
31-
required: true
32-
type: string
33-
description: "The doc site URL"
21+
description: "The AWS role to assume."
22+
production:
23+
required: false
24+
default: "false"
25+
type: boolean
26+
description: "If true, the files will be deployed to the production site. Otherwise they will be deployed to the preview site."
27+
temporary:
28+
required: false
29+
default: "true"
30+
type: boolean
31+
description: "If true, the files will be marked as temporary and deleted after 14 days. Otherwise they will persist in S3 indefinitely."
3432
```
3533
3634
## Example
@@ -44,8 +42,7 @@ Here is an example that syncs from the local path `temp/blog` to the blog sectio
4442
with:
4543
source: temp/blog
4644
destination: deephaven/deephaven.io/blog
47-
bucket: ${{ vars.DOCS_PROD_BUCKET }} # or ${{ vars.DOCS_PREVIEW_BUCKET }}
48-
credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }}
49-
cache-bust-token: ${{ secrets.DOCS_CACHE_BUST_TOKEN }}
50-
docs-url: ${{ vars.DOCS_PROD_URL }} # or ${{ vars.DOCS_PREVIEW_URL }}
45+
production: true # false for pr previews
46+
temporary: false # true will delete non-production files after 14 days
47+
aws-role: ${{ vars.DOCS_AWS_ROLE }}
5148
```

action.yml

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Sync Salmon Directory
2-
description: Syncs a directory to a Google Cloud bucket using rclone.
2+
description: Syncs a directory to a bucket using rclone.
33
author: "deephaven"
44
inputs:
55
source:
@@ -10,22 +10,20 @@ inputs:
1010
required: true
1111
type: string
1212
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-
bucket:
13+
aws-role:
1414
required: true
1515
type: string
16-
description: "The Google Cloud bucket to sync to."
17-
credentials:
18-
required: true
19-
type: string
20-
description: "The Google Cloud credentials. Should be base64 encoded."
21-
cache-bust-token:
22-
required: true
23-
type: string
24-
description: "The cache-bust token"
25-
docs-url:
26-
required: true
27-
type: string
28-
description: "The doc site URL"
16+
description: "The AWS role to assume."
17+
production:
18+
required: false
19+
default: "false"
20+
type: boolean
21+
description: "If true, the files will be deployed to the production site. Otherwise they will be deployed to the preview site."
22+
temporary:
23+
required: false
24+
default: "true"
25+
type: boolean
26+
description: "If true, the files will be marked as temporary and deleted after 14 days. Otherwise they will persist in S3 indefinitely."
2927

3028
runs:
3129
using: "composite"
@@ -35,28 +33,20 @@ runs:
3533
with:
3634
version: v1.68.1
3735

38-
- name: Decode credentials
39-
shell: bash
40-
run: |
41-
echo $RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS_ENCODED | base64 --decode > $HOME/credentials.json
42-
env:
43-
RCLONE_GCS_SERVICE_ACCOUNT_CREDENTIALS_ENCODED: ${{ inputs.credentials }}
36+
- name: AWS OIDC Auth
37+
uses: aws-actions/configure-aws-credentials@v4
38+
with:
39+
aws-region: us-east-2 # Docs are hosted in us-east-2
40+
role-to-assume: ${{ inputs.aws-role }}
4441

4542
- name: Sync source to destination
4643
shell: bash
4744
env:
48-
RCLONE_CONFIG_GCS_TYPE: "google cloud storage"
49-
RCLONE_GCS_SERVICE_ACCOUNT_FILE: $HOME/credentials.json
50-
RCLONE_GCS_BUCKET_POLICY_ONLY: "true"
51-
run: rclone sync ${{ inputs.source }} gcs:${{ inputs.bucket }}/${{ inputs.destination }}
52-
53-
- name: Bust cache
54-
shell: bash
55-
env:
56-
CACHE_BUST_TOKEN: ${{ inputs.cache-bust-token }}
45+
RCLONE_S3_PROVIDER: AWS
46+
RCLONE_S3_REGION: us-east-2
47+
RCLONE_S3_ENV_AUTH: true
48+
RCLONE_S3_NO_CHECK_BUCKET: true # Don't try to create the bucket and fail if it doesn't exist
49+
# Check temporary != 'false' so any other value is marked as temporary since there's no actual validation of boolean or required inputs
50+
# The production bucket doesn't have a lifecycle rule, so omitting temporary just results in a tag on files. They won't actually be deleted
5751
run: |
58-
curl --fail-with-body --show-error --silent \
59-
--request POST \
60-
--header "authorization: Bearer $CACHE_BUST_TOKEN" \
61-
--data "{ \"tags\": [ \"${{ inputs.destination }}\" ]}" \
62-
--url ${{ inputs.docs-url }}/api/cache-bust/
52+
rclone sync --fast-list --checksum ${{ inputs.source }} :s3:${{ inputs.production == 'true' && 'deephaven-docs' || 'deephaven-docs-preview' }}/${{ inputs.destination }} ${{ inputs.temporary != 'false' && '--header-upload "x-amz-tagging: temporary=true"' || '' }}

0 commit comments

Comments
 (0)