sync images from www.tea.xyz/Images/packages to pr-bucket/Images/packages

This commit is contained in:
neil 2022-11-19 13:48:37 +08:00
parent b7f8ee5b2c
commit 6c2a28e207
2 changed files with 23 additions and 7 deletions

View file

@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
# update packages.json data with relative thumb image url path
# rebuild pages
# download images from www.tea.xyz/Images/packages to
# cmd: $ ./prepare-thumb-images.sh srcJson targetPath # cmd: $ ./prepare-thumb-images.sh srcJson targetPath
# sample: $ .github/prepare-thumb-images.sh src/data/packages.json src/static/Images/packages/ # sample: $ .github/prepare-thumb-images.sh src/data/packages.json src/static/Images/packages/
# create packages folder: where airtable images will be DLd # create packages folder: where airtable images will be DLd
mkdir -p ./packages_thumbs_images
packages="cat $1" packages="cat $1"
temp_packages="./src/data/temp.json" temp_packages="./src/data/temp.json"
cp $1 $temp_packages cp $1 $temp_packages
@ -11,16 +14,15 @@ for row in $($packages | jq -r '.[] | @base64'); do
_jq() { _jq() {
echo ${row} | base64 --decode | jq -r ${1} echo ${row} | base64 --decode | jq -r ${1}
} }
dl_url=$(_jq '.thumb_image_url') dl_url=$(_jq '.thumb_image_url')
if [[ $dl_url == *"airtable"* ]]; then if [[ $dl_url == *"tea.xyz"* ]]; then
filename=$(basename -- "$dl_url") filename=$(basename -- "$dl_url")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
slug=$(_jq '.slug') slug=$(_jq '.slug')
outputPath=$2/$(_jq '.slug').$extension
new_thumb_image_url="https://tea.xyz/Images/packages/$slug.jpg" new_thumb_image_url="/Images/packages/$filename.$extension"
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) updated_packages=$(jq '(.[] | select(.slug == "'$slug'") | .thumb_image_url) |= "'$new_thumb_image_url'"' ./src/data/temp.json)
echo $updated_packages > $temp_packages echo $updated_packages > $temp_packages
echo "update $slug" echo "update $slug"

View file

@ -62,6 +62,17 @@ jobs:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# update packages json data and rebuild again # update packages json data and rebuild again
- name: make images relative path to preview site
uses: getneil/jq-action@v1
with:
cmd: '.github/sync-thumb-images.sh src/data/packages.json'
# intentional to rebuild packages again with relative image data
# the first one to test it against prod resources via lychee
- uses: teaxyz/setup@v0
with:
target: build
- run: echo "TeaXYZ-${STAGE}" - run: echo "TeaXYZ-${STAGE}"
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
@ -82,7 +93,10 @@ jobs:
working-directory: .cdk working-directory: .cdk
# sync images from www.tea.xyz/Images/packages to wherever bucket you are # sync images from www.tea.xyz/Images/packages to wherever bucket you are
- run: echo "TeaXYZ-${STAGE}" - run: |
aws s3 sync s3://www.tea.xyz/Images/packages \
s3://TeaXYZ-${STAGE}/Images/packages
- name: Seal Deployment - name: Seal Deployment
uses: bobheadxi/deployments@v1 uses: bobheadxi/deployments@v1
if: always() if: always()