#195 rely completely in packages.json data for images

This commit is contained in:
neil 2022-11-19 13:00:03 +08:00
parent a1f11758ae
commit 0f1883a78c
3 changed files with 1 additions and 63 deletions

View file

@ -1,31 +0,0 @@
#!/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

View file

@ -39,21 +39,6 @@ jobs:
with:
cmd: '.github/build-package-pages.sh src/data/packages.json src/content'
- name: Download package thumbnails from Airtable
uses: getneil/jq-action@v1
with:
cmd: '.github/prepare-thumb-images.sh src/data/packages.json'
- name: Upload package thumbnails to AWS S3
uses: jakejarvis/s3-sync-action@master
env:
AWS_S3_BUCKET: www.tea.xyz
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: 'packages_thumbs_images'
DEST_DIR: 'Images/packages'
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- uses: teaxyz/setup@v0
with:
@ -76,8 +61,6 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- run: cp -R packages_thumbs_images public/Images/packages
# cache-control of 10 mins because we *need* to be able to update
# this and have people see the results can be fixed well with a static site builder
- run: |
@ -85,6 +68,7 @@ jobs:
--metadata-directive REPLACE \
--cache-control max-age=600 \
--exclude '.git/*' --exclude '.github/*' \
--exclude 'Images/packages/*' \
--exclude 'pour.sh' \
--exclude 'tea.white-paper*.pdf' \
--exclude '*.md' \

View file

@ -47,21 +47,6 @@ jobs:
with:
cmd: '.github/build-package-pages.sh src/data/packages.json src/content'
- name: Download package thumbnails from Airtable
uses: getneil/jq-action@v1
with:
cmd: '.github/prepare-thumb-images.sh src/data/packages.json'
- name: Upload package thumbnails to AWS S3
uses: jakejarvis/s3-sync-action@master
env:
AWS_S3_BUCKET: www.tea.xyz
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: 'packages_thumbs_images'
DEST_DIR: 'Images/packages'
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- uses: teaxyz/setup@v0