mirror of
https://github.com/ivabus/www
synced 2024-11-25 07:15:06 +03:00
load images from airtable attachments as a static file within our deployment
This commit is contained in:
parent
8319762a1e
commit
e171f2b934
3 changed files with 106 additions and 68 deletions
30
.github/prepare-thumb-images.sh
vendored
Executable file
30
.github/prepare-thumb-images.sh
vendored
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# cmd: $ ./prepare-thumb-images.sh srcJson targetPath
|
||||||
|
# sample: $ .github/prepare-thumb-images.sh src/data/packages.json src/static/Images/packages/
|
||||||
|
|
||||||
|
mkdir -p $2
|
||||||
|
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 == *"https://dl.airtable.com/.attachments"* ]]; then
|
||||||
|
filename=$(basename -- "$dl_url")
|
||||||
|
extension="${filename##*.}"
|
||||||
|
filename="${filename%.*}"
|
||||||
|
slug=$(_jq '.slug')
|
||||||
|
outputPath=$2/$(_jq '.slug').$extension
|
||||||
|
new_thumb_image_url="/Images/packages/$slug.$extension"
|
||||||
|
curl $dl_url -o $2/$slug.$extension
|
||||||
|
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
|
143
.github/workflows/staging.yml
vendored
143
.github/workflows/staging.yml
vendored
|
@ -29,83 +29,90 @@ jobs:
|
||||||
args: -c "cd ./lambdas && serverless deploy"
|
args: -c "cd ./lambdas && serverless deploy"
|
||||||
entrypoint: /bin/sh
|
entrypoint: /bin/sh
|
||||||
|
|
||||||
# deploy:
|
deploy:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - name: inject slug/short variables
|
- name: inject slug/short variables
|
||||||
# uses: rlespinasse/github-slug-action@v3.x
|
uses: rlespinasse/github-slug-action@v3.x
|
||||||
# - name: Set STAGE variable in environment for next steps
|
- name: Set STAGE variable in environment for next steps
|
||||||
# run: echo "STAGE=pr-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}" >> $GITHUB_ENV
|
run: echo "STAGE=pr-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
# - name: Create Deployment
|
- name: Create Deployment
|
||||||
# uses: bobheadxi/deployments@v1
|
uses: bobheadxi/deployments@v1
|
||||||
# id: deployment
|
id: deployment
|
||||||
# with:
|
with:
|
||||||
# step: start
|
step: start
|
||||||
# env: ${{ env.STAGE }}
|
env: ${{ env.STAGE }}
|
||||||
# ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
# override: true
|
override: true
|
||||||
|
|
||||||
# - uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
# - name: Apply Staging Configuration
|
- name: Apply Staging Configuration
|
||||||
# run: |
|
run: |
|
||||||
# sed -i -e 's/^baseURL\s*=.*$/baseUrl = ""/i' config.toml
|
sed -i -e 's/^baseURL\s*=.*$/baseUrl = ""/i' config.toml
|
||||||
# echo "relativeurls = true" >>config.toml
|
echo "relativeurls = true" >>config.toml
|
||||||
# working-directory: src
|
working-directory: src
|
||||||
|
|
||||||
# - name: Copy packages.json summary from dist.tea.xyz
|
- name: Copy packages.json summary from dist.tea.xyz
|
||||||
# uses: prewk/s3-cp-action@v2
|
uses: prewk/s3-cp-action@v2
|
||||||
# with:
|
with:
|
||||||
# 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 }}
|
||||||
# source: 's3://dist.tea.xyz/mock_packages.json'
|
source: 's3://dist.tea.xyz/mock_packages.json'
|
||||||
# dest: './src/data/packages.json'
|
dest: './src/data/packages.json'
|
||||||
|
|
||||||
# - name: Create Package Detail Pages from packages.json
|
- name: Create Package Detail Pages from packages.json
|
||||||
# uses: getneil/jq-action@v1
|
uses: getneil/jq-action@v1
|
||||||
# id: version
|
id: version
|
||||||
# with:
|
with:
|
||||||
# cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages'
|
cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages'
|
||||||
|
|
||||||
# - run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
- name: Download package thumbnail images
|
||||||
|
uses: getneil/jq-action@v1
|
||||||
|
id: version
|
||||||
|
with:
|
||||||
|
cmd: '.github/prepare-thumb-images.sh src/data/packages.json ./src/static/Images/packages/'
|
||||||
|
|
||||||
# - uses: teaxyz/setup@v0
|
|
||||||
# with:
|
|
||||||
# target: build
|
|
||||||
|
|
||||||
# - name: Check for broken links
|
- run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
||||||
# uses: lycheeverse/lychee-action@v1
|
|
||||||
# with:
|
|
||||||
# fail: true
|
|
||||||
# args: --verbose --no-progress './public/**/*.md' './public/**/*.html'
|
|
||||||
# env:
|
|
||||||
# GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
||||||
|
|
||||||
# - uses: actions/setup-node@v3
|
- uses: teaxyz/setup@v0
|
||||||
# with:
|
with:
|
||||||
# node-version: 14
|
target: build
|
||||||
# - uses: bahmutov/npm-install@v1
|
|
||||||
# with:
|
|
||||||
# working-directory: .cdk
|
|
||||||
|
|
||||||
# - uses: aws-actions/configure-aws-credentials@v1
|
- name: Check for broken links
|
||||||
# with:
|
uses: lycheeverse/lychee-action@v1
|
||||||
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
with:
|
||||||
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
fail: true
|
||||||
# aws-region: us-east-1
|
args: --verbose --no-progress './public/**/*.md' './public/**/*.html'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
|
||||||
# - name: Deploy to AWS
|
- uses: actions/setup-node@v3
|
||||||
# id: cdk_deploy
|
with:
|
||||||
# run: yarn deploy
|
node-version: 14
|
||||||
# working-directory: .cdk
|
- uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
working-directory: .cdk
|
||||||
|
|
||||||
|
- uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
with:
|
||||||
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
|
||||||
|
- name: Deploy to AWS
|
||||||
|
id: cdk_deploy
|
||||||
|
run: yarn deploy
|
||||||
|
working-directory: .cdk
|
||||||
|
|
||||||
# - name: Seal Deployment
|
- name: Seal Deployment
|
||||||
# uses: bobheadxi/deployments@v1
|
uses: bobheadxi/deployments@v1
|
||||||
# if: always()
|
if: always()
|
||||||
# with:
|
with:
|
||||||
# step: finish
|
step: finish
|
||||||
# status: ${{ job.status }}
|
status: ${{ job.status }}
|
||||||
# deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
||||||
# env: ${{ env.STAGE }}
|
env: ${{ env.STAGE }}
|
||||||
# env_url: ${{ steps.cdk_deploy.outputs.env_url }}
|
env_url: ${{ steps.cdk_deploy.outputs.env_url }}
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,3 +27,4 @@ cdk.out
|
||||||
|
|
||||||
# initially committed _sample.md only the rest will be ignored
|
# initially committed _sample.md only the rest will be ignored
|
||||||
src/content/packages/*
|
src/content/packages/*
|
||||||
|
src/static/Images/packages/*
|
Loading…
Reference in a new issue