Skip to content

Commit

Permalink
gh-actions/gcs/artefact/sync: Fix redirects (#2478)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Nov 25, 2024
1 parent 4ba11b6 commit 0317bc8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gh-actions/gcs/artefact/sync/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
direction:
type: string
default: up
index-file:
type: string
default: index.html
path:
type: string
required: true
Expand Down Expand Up @@ -36,7 +39,7 @@ runs:
TMP_REDIRECT=$(mktemp -d)
TMP_REDIRECT="${TMP_REDIRECT}/${REDIRECT_PATH}"
mkdir -p "$TMP_REDIRECT"
echo "redirect=${BUCKET_PATH}/${REDIRECT_PATH}" >> $GITHUB_OUTPUT
echo "redirect=${{ inputs.bucket }}/${REDIRECT_PATH}" >> $GITHUB_OUTPUT
echo "redirect-tmp=${TMP_REDIRECT}" >> $GITHUB_OUTPUT
shell: bash
env:
Expand All @@ -52,20 +55,21 @@ runs:
-mq rsync \
-dr "${{ steps.paths.outputs.upload }}" \
"gs://${{ steps.paths.outputs.bucket }}"
echo "Artifacts uploaded to: https://storage.googleapis.com/${{ steps.paths.outputs.bucket }}" >&2
echo "Artifacts uploaded to: https://storage.googleapis.com/${{ steps.paths.outputs.bucket }}/${{ inputs.index-file }}" >&2
shell: bash

- name: Add redirect
if: ${{ steps.paths.outputs.redirect }}
run: |
{
echo "<meta http-equiv=\"refresh\""
echo " content=\"0; URL='https://storage.googleapis.com/${{ steps.paths.outputs.bucket }}/index.html'\" />"
} > "${{ steps.paths.outputs.redirect-tmp }}/index.html"
echo " content=\"0; URL='https://storage.googleapis.com/${{ steps.paths.outputs.bucket }}/${{ inputs.index-file }}'\" />"
} > "${{ steps.paths.outputs.redirect-tmp }}/${{ inputs.index-file }}"
echo "Uploading redirect to gs://${{ steps.paths.outputs.redirect }} ..." >&2
gsutil \
-h "Cache-Control:no-cache,max-age=0" \
-mq rsync \
-dr "${{ steps.paths.outputs.redirect-tmp }}" \
"gs://${{ steps.paths.outputs.redirect }}"
echo "Redirect uploaded to: https://storage.googleapis.com/${{ steps.paths.outputs.redirect }}/${{ inputs.index-file }}" >&2
shell: bash

0 comments on commit 0317bc8

Please sign in to comment.