mirror of
https://github.com/ivabus/www
synced 2024-11-22 15:25:06 +03:00
Merge pull request #196 from teaxyz/bugfix-new-image-loading-strategy
#195 rely completely in packages.json data for images
This commit is contained in:
commit
e87feae2af
3 changed files with 36 additions and 39 deletions
|
@ -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"
|
18
.github/workflows/cd.yml
vendored
18
.github/workflows/cd.yml
vendored
|
@ -39,21 +39,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
cmd: '.github/build-package-pages.sh src/data/packages.json src/content'
|
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 }}
|
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
with:
|
with:
|
||||||
|
@ -75,8 +60,6 @@ jobs:
|
||||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
aws-region: us-east-1
|
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
|
# 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
|
# this and have people see the results can be fixed well with a static site builder
|
||||||
|
@ -85,6 +68,7 @@ jobs:
|
||||||
--metadata-directive REPLACE \
|
--metadata-directive REPLACE \
|
||||||
--cache-control max-age=600 \
|
--cache-control max-age=600 \
|
||||||
--exclude '.git/*' --exclude '.github/*' \
|
--exclude '.git/*' --exclude '.github/*' \
|
||||||
|
--exclude 'Images/packages/*' \
|
||||||
--exclude 'pour.sh' \
|
--exclude 'pour.sh' \
|
||||||
--exclude 'tea.white-paper*.pdf' \
|
--exclude 'tea.white-paper*.pdf' \
|
||||||
--exclude '*.md' \
|
--exclude '*.md' \
|
||||||
|
|
43
.github/workflows/staging.yml
vendored
43
.github/workflows/staging.yml
vendored
|
@ -47,21 +47,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
cmd: '.github/build-package-pages.sh src/data/packages.json src/content'
|
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 }}
|
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
||||||
|
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
|
@ -76,6 +61,18 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 14
|
||||||
|
@ -93,7 +90,21 @@ jobs:
|
||||||
id: cdk_deploy
|
id: cdk_deploy
|
||||||
run: yarn deploy
|
run: yarn deploy
|
||||||
working-directory: .cdk
|
working-directory: .cdk
|
||||||
|
|
||||||
|
- name: get cdk bucket
|
||||||
|
id: DEPLOY_BUCKET
|
||||||
|
run: |
|
||||||
|
BUCKET=$(aws s3 ls | grep $(echo teaxyz-pr-$GITHUB_REF_SLUG_URL | sed "s/-merge//") | grep -o '[^ ]*$')
|
||||||
|
echo "bucket=$BUCKET" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: cp package images from prod to preview bucket
|
||||||
|
run: |
|
||||||
|
aws s3 cp s3://www.tea.xyz/Images/packages \
|
||||||
|
s3://$NEW_BUCKET/Images/packages \
|
||||||
|
--recursive
|
||||||
|
env:
|
||||||
|
NEW_BUCKET: ${{ steps.DEPLOY_BUCKET.outputs.bucket }}
|
||||||
|
|
||||||
- name: Seal Deployment
|
- name: Seal Deployment
|
||||||
uses: bobheadxi/deployments@v1
|
uses: bobheadxi/deployments@v1
|
||||||
if: always()
|
if: always()
|
||||||
|
|
Loading…
Reference in a new issue