From fb788fbc4c5a7d866dc994e0b43cd5040ce81b68 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 29 Oct 2022 10:31:10 +0800 Subject: [PATCH 1/4] sync packages thumbnails into production cdn --- .github/prepare-thumb-images.sh | 12 +++-- .github/workflows/staging.yml | 78 ++++++++++++++++----------------- src/data/packages.json | 2 +- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/.github/prepare-thumb-images.sh b/.github/prepare-thumb-images.sh index c4d2c9f..4a2b9f7 100755 --- a/.github/prepare-thumb-images.sh +++ b/.github/prepare-thumb-images.sh @@ -2,7 +2,8 @@ # cmd: $ ./prepare-thumb-images.sh srcJson targetPath # sample: $ .github/prepare-thumb-images.sh src/data/packages.json src/static/Images/packages/ -mkdir -p $2 +# 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 @@ -18,8 +19,8 @@ for row in $($packages | jq -r '.[] | @base64'); do 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 + new_thumb_image_url="https://tea.xyz/Images/packages/$slug.$extension" + curl $dl_url -o ./packages_thumbs_images/$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" @@ -27,4 +28,7 @@ for row in $($packages | jq -r '.[] | @base64'); do done # replace packages.json with the updated version with localized image links -mv $temp_packages $1 \ No newline at end of file +mv $temp_packages $1 + +# upload thumb images to production cdn +aws s3 sync ./packages_thumbs_images s3://www.tea.xyz/Images/packages \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 5936fe4..ff5b9df 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -92,49 +92,49 @@ jobs: with: cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages' - # - name: Download package thumbnail images - # uses: getneil/jq-action@v1 - # with: - # cmd: '.github/prepare-thumb-images.sh src/data/packages.json ./src/static/Images/packages/' - - - run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }} - - - uses: teaxyz/setup@v0 - with: - target: build - - - name: Check for broken links - 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 - with: - node-version: 14 - - 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 - uses: bobheadxi/deployments@v1 - if: always() + - name: Download and Upload package thumbnails from Airtable + uses: getneil/jq-action@v1 with: - step: finish - status: ${{ job.status }} - deployment_id: ${{ steps.deployment.outputs.deployment_id }} - env: ${{ env.STAGE }} - env_url: ${{ steps.cdk_deploy.outputs.env_url }} + cmd: '.github/prepare-thumb-images.sh src/data/packages.json' + + # - run: .github/mk-pantry-accessible.sh ${{ secrets.TEMP_JACOBS_GITHUB_PAT }} + + # - uses: teaxyz/setup@v0 + # with: + # target: build + + # - name: Check for broken links + # 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 + # with: + # node-version: 14 + # - uses: bahmutov/npm-install@v1 + # with: + # working-directory: .cdk + + # - name: Deploy to AWS + # id: cdk_deploy + # run: yarn deploy + # working-directory: .cdk + + # - name: Seal Deployment + # uses: bobheadxi/deployments@v1 + # if: always() + # with: + # step: finish + # status: ${{ job.status }} + # deployment_id: ${{ steps.deployment.outputs.deployment_id }} + # env: ${{ env.STAGE }} + # env_url: ${{ steps.cdk_deploy.outputs.env_url }} diff --git a/src/data/packages.json b/src/data/packages.json index 6549ad0..4ad471e 100644 --- a/src/data/packages.json +++ b/src/data/packages.json @@ -2,7 +2,7 @@ { "name": "mpdecimal", "full_name": "mpdecimal", - "desc": "Library for decimal floating point arithmetic", + "desc": "Library for decimal floating point arithmetics", "homepage": "https://www.bytereef.org/mpdecimal/", "version": "2.5.1", "installs": 3986221, From 1c18bb9dbc6e575575e5b46cf04b9507a6f2de53 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 29 Oct 2022 10:43:03 +0800 Subject: [PATCH 2/4] test: sync thumb images --- .github/prepare-thumb-images.sh | 5 +---- .github/workflows/cd.yml | 1 + .github/workflows/staging.yml | 26 +++++++++++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/prepare-thumb-images.sh b/.github/prepare-thumb-images.sh index 4a2b9f7..1a8d9c8 100755 --- a/.github/prepare-thumb-images.sh +++ b/.github/prepare-thumb-images.sh @@ -28,7 +28,4 @@ for row in $($packages | jq -r '.[] | @base64'); do done # replace packages.json with the updated version with localized image links -mv $temp_packages $1 - -# upload thumb images to production cdn -aws s3 sync ./packages_thumbs_images s3://www.tea.xyz/Images/packages \ No newline at end of file +mv $temp_packages $1 \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 013357c..0cf66e1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -71,6 +71,7 @@ jobs: --exclude 'pour.sh' \ --exclude 'tea.white-paper*.pdf' \ --exclude '*.md' \ + --exclude 'public/Images/packages/*' \ --delete #TODO create a github-action that can be used to parse the diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index ff5b9df..bdea9f9 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -92,17 +92,23 @@ jobs: with: cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages' - - 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: Download and Upload package thumbnails from Airtable + - 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 + with: + args: --acl public-read --follow-symlinks + 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 @@ -124,6 +130,12 @@ jobs: # 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 From b2a098732218340ceb85343d83e129332c611b82 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 29 Oct 2022 10:46:13 +0800 Subject: [PATCH 3/4] fix: remove args for s3 ACLs --- .github/workflows/staging.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index bdea9f9..1279561 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -99,8 +99,6 @@ jobs: - name: Upload package thumbnails to AWS S3 uses: jakejarvis/s3-sync-action@master - with: - args: --acl public-read --follow-symlinks env: AWS_S3_BUCKET: www.tea.xyz AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From b14798f17b9bb36efa712c24819aa6b48460c673 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 29 Oct 2022 10:51:28 +0800 Subject: [PATCH 4/4] uncomment disabled pipeline tasks --- .github/workflows/cd.yml | 15 ++++++++ .github/workflows/staging.yml | 70 +++++++++++++++++------------------ 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0cf66e1..06f9567 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -39,6 +39,21 @@ jobs: with: cmd: '.github/build-package-pages.sh src/data/packages.json src/content/packages' + - 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: diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 1279561..973fb5b 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -107,44 +107,44 @@ jobs: 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 - # with: - # target: build + - uses: teaxyz/setup@v0 + with: + target: build - # - name: Check for broken links - # uses: lycheeverse/lychee-action@v1 - # with: - # fail: true - # args: --verbose --no-progress './public/**/*.md' './public/**/*.html' - # env: - # GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Check for broken links + 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 - # with: - # node-version: 14 - # - uses: bahmutov/npm-install@v1 - # with: - # working-directory: .cdk + - uses: actions/setup-node@v3 + with: + node-version: 14 + - 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 + - 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: Deploy to AWS + id: cdk_deploy + run: yarn deploy + working-directory: .cdk - # - name: Seal Deployment - # uses: bobheadxi/deployments@v1 - # if: always() - # with: - # step: finish - # status: ${{ job.status }} - # deployment_id: ${{ steps.deployment.outputs.deployment_id }} - # env: ${{ env.STAGE }} - # env_url: ${{ steps.cdk_deploy.outputs.env_url }} + - name: Seal Deployment + uses: bobheadxi/deployments@v1 + if: always() + with: + step: finish + status: ${{ job.status }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + env: ${{ env.STAGE }} + env_url: ${{ steps.cdk_deploy.outputs.env_url }}