From b7f8ee5b2cafac86d4b8925ae5cd50b4a18c2c32 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 19 Nov 2022 13:29:19 +0800 Subject: [PATCH] test env --- .github/sync-thumb-images.sh | 31 +++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 6 +++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 .github/sync-thumb-images.sh diff --git a/.github/sync-thumb-images.sh b/.github/sync-thumb-images.sh new file mode 100755 index 0000000..079c935 --- /dev/null +++ b/.github/sync-thumb-images.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# cmd: $ ./prepare-thumb-images.sh srcJson targetPath +# sample: $ .github/prepare-thumb-images.sh src/data/packages.json src/static/Images/packages/ + +# create packages folder: where airtable images will be DLd +mkdir -p ./packages_thumbs_images +packages="cat $1" +temp_packages="./src/data/temp.json" +cp $1 $temp_packages +for row in $($packages | jq -r '.[] | @base64'); do + _jq() { + echo ${row} | base64 --decode | jq -r ${1} + } + + dl_url=$(_jq '.thumb_image_url') + if [[ $dl_url == *"airtable"* ]]; then + filename=$(basename -- "$dl_url") + extension="${filename##*.}" + filename="${filename%.*}" + slug=$(_jq '.slug') + outputPath=$2/$(_jq '.slug').$extension + new_thumb_image_url="https://tea.xyz/Images/packages/$slug.jpg" + curl $dl_url -o ./packages_thumbs_images/$slug.jpg + updated_packages=$(jq '(.[] | select(.slug == "'$slug'") | .thumb_image_url) |= "'$new_thumb_image_url'"' ./src/data/temp.json) + echo $updated_packages > $temp_packages + echo "update $slug" + fi +done + +# replace packages.json with the updated version with localized image links +mv $temp_packages $1 \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 62b5221..591be00 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -61,6 +61,8 @@ jobs: env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + # update packages json data and rebuild again + - run: echo "TeaXYZ-${STAGE}" - uses: actions/setup-node@v3 with: node-version: 14 @@ -78,7 +80,9 @@ jobs: id: cdk_deploy run: yarn deploy working-directory: .cdk - + + # sync images from www.tea.xyz/Images/packages to wherever bucket you are + - run: echo "TeaXYZ-${STAGE}" - name: Seal Deployment uses: bobheadxi/deployments@v1 if: always()