From f1e3e62c2d3a0fb13622ae009da85802dcb49e2b Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Wed, 12 Feb 2025 23:43:12 -0600 Subject: [PATCH 1/5] Add cache bust to action --- README.md | 32 ++++++++++++++++++++------------ action.yml | 37 +++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5fea360..7c1eaf2 100644 --- a/README.md +++ b/README.md @@ -4,40 +4,48 @@ This is a Github Action that syncs a folder to a Google Cloud bucket using `rclo 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 -``` + +```yml inputs: source: required: true type: string - description: 'The source directory to sync.' + 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.' + 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." bucket: required: true type: string - description: 'The Google Cloud bucket to sync to.' + description: "The Google Cloud bucket to sync to." credentials: required: true type: string - description: 'The Google Cloud credentials. Should be base64 encoded.' + description: "The Google Cloud credentials. Should be base64 encoded." + cache-bust-token: + required: true + type: string + description: "The cache-bust token" + cache-bust-url: + required: true + type: string + description: "The cache-bust URL" ``` ## 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. -``` + +```yml - 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 }} + bucket: ${{ vars.DOCS_GOOGLE_CLOUD_BUCKET }} # or ${{ vars.DOCS_PREVIEW_BUCKET }} credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} + cache-bust-token: ${{ secrets.CACHE_BUST_TOKEN }} + cache-bust-url: ${{ vars.DOCS_PROD_CACHE_BUST_URL }} # or ${{ vars.DOCS_PREVIEW_CACHE_BUST_URL }} ``` diff --git a/action.yml b/action.yml index 9a2a514..344c021 100644 --- a/action.yml +++ b/action.yml @@ -1,27 +1,31 @@ name: Sync Salmon Directory description: Syncs a directory to a Google Cloud bucket using rclone. -author: 'deephaven' +author: "deephaven" inputs: source: required: true type: string - description: 'The source directory to sync.' + 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.' + 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." bucket: required: true type: string - description: 'The Google Cloud bucket to sync to.' + description: "The Google Cloud bucket to sync to." credentials: required: true type: string - description: 'The Google Cloud credentials. Should be base64 encoded.' + description: "The Google Cloud credentials. Should be base64 encoded." + cache-bust-token: + required: true + type: string + description: "The cache-bust token" + cache-bust-url: + required: true + type: string + description: "The cache-bust URL" runs: using: "composite" @@ -37,13 +41,22 @@ runs: 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 }} \ No newline at end of file + run: rclone sync ${{ inputs.source }} gcs:${{ inputs.bucket }}/${{ inputs.destination }} + + - name: Bust cache + shell: bash + env: + CACHE_BUST_TOKEN: ${{ inputs.cache-bust-token }} + run: | + curl --fail-with-body --show-error --silent \ + --request POST \ + --header "authorization: Bearer $CACHE_BUST_TOKEN" \ + --data "{ \"tags\": [ \"${{ inputs.destination }}\" ]}" \ + --url ${{ inputs.cache-bust-url }} From b03d656fec29edd6aae13785e53d442d22b2c70f Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Wed, 12 Feb 2025 23:58:52 -0600 Subject: [PATCH 2/5] Update secret name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c1eaf2..6f770bd 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,6 @@ Here is an example that syncs from the local path `temp/blog` to the blog sectio destination: deephaven/deephaven.io/blog bucket: ${{ vars.DOCS_GOOGLE_CLOUD_BUCKET }} # or ${{ vars.DOCS_PREVIEW_BUCKET }} credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} - cache-bust-token: ${{ secrets.CACHE_BUST_TOKEN }} + cache-bust-token: ${{ secrets.DOCS_CACHE_BUST_TOKEN }} cache-bust-url: ${{ vars.DOCS_PROD_CACHE_BUST_URL }} # or ${{ vars.DOCS_PREVIEW_CACHE_BUST_URL }} ``` From 8674525a4eea8f85172928ac0d57f2f54ed81e1f Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Thu, 13 Feb 2025 15:04:16 -0600 Subject: [PATCH 3/5] Align bucket variable names --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f770bd..34c4e44 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Here is an example that syncs from the local path `temp/blog` to the blog sectio with: source: temp/blog destination: deephaven/deephaven.io/blog - bucket: ${{ vars.DOCS_GOOGLE_CLOUD_BUCKET }} # or ${{ vars.DOCS_PREVIEW_BUCKET }} + bucket: ${{ vars.DOCS_PROD_BUCKET }} # or ${{ vars.DOCS_PREVIEW_BUCKET }} credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} cache-bust-token: ${{ secrets.DOCS_CACHE_BUST_TOKEN }} cache-bust-url: ${{ vars.DOCS_PROD_CACHE_BUST_URL }} # or ${{ vars.DOCS_PREVIEW_CACHE_BUST_URL }} From a767b57a979ba1cbf58fb64fda410b2d598c20b2 Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Thu, 13 Feb 2025 15:14:17 -0600 Subject: [PATCH 4/5] Update url input name --- README.md | 6 +++--- action.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 34c4e44..b870b15 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,10 @@ inputs: required: true type: string description: "The cache-bust token" - cache-bust-url: + docs-url: required: true type: string - description: "The cache-bust URL" + description: "The doc site URL" ``` ## Example @@ -47,5 +47,5 @@ Here is an example that syncs from the local path `temp/blog` to the blog sectio bucket: ${{ vars.DOCS_PROD_BUCKET }} # or ${{ vars.DOCS_PREVIEW_BUCKET }} credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} cache-bust-token: ${{ secrets.DOCS_CACHE_BUST_TOKEN }} - cache-bust-url: ${{ vars.DOCS_PROD_CACHE_BUST_URL }} # or ${{ vars.DOCS_PREVIEW_CACHE_BUST_URL }} + docs-url: ${{ vars.DOCS_PROD_URL }} # or ${{ vars.DOCS_PREVIEW_URL }} ``` diff --git a/action.yml b/action.yml index 344c021..7137244 100644 --- a/action.yml +++ b/action.yml @@ -22,10 +22,10 @@ inputs: required: true type: string description: "The cache-bust token" - cache-bust-url: + docs-url: required: true type: string - description: "The cache-bust URL" + description: "The doc site URL" runs: using: "composite" @@ -59,4 +59,4 @@ runs: --request POST \ --header "authorization: Bearer $CACHE_BUST_TOKEN" \ --data "{ \"tags\": [ \"${{ inputs.destination }}\" ]}" \ - --url ${{ inputs.cache-bust-url }} + --url ${{ inputs.docs-url }}/api/cache-bust/ From 6c884df011056a7bb4e48858705e6767871f61c7 Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Thu, 13 Feb 2025 16:33:41 -0600 Subject: [PATCH 5/5] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b870b15..552bd2f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # salmon-sync -This is a Github Action that syncs a folder to a Google Cloud bucket using `rclone`. +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. 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