Skip to content

Commit

Permalink
🐛 Fix product information fetching failing
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Jan 6, 2025
1 parent 2e9af3a commit a71547d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: 🚀 Deploy

on:
workflow_dispatch:
inputs:
force_deploy:
description: 'Force the deployment (even if no file changes)'
required: true
type: boolean
default: false
push:
branches:
- main
Expand Down Expand Up @@ -50,40 +56,40 @@ jobs:
- 'packages/backend-elysia/**'
- name: Set up QEMU
if: steps.changes.outputs.backend == 'true'
if: steps.changes.outputs.backend == 'true' || github.event.inputs.force_deploy == 'true'
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64

- name: Set up Docker Buildx
if: steps.changes.outputs.backend == 'true'
if: steps.changes.outputs.backend == 'true' || github.event.inputs.force_deploy == 'true'
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64

- name: "🔨 Install dependencies"
if: steps.changes.outputs.deployRequired == 'true'
if: steps.changes.outputs.deployRequired == 'true' || github.event.inputs.force_deploy == 'true'
run: bun install --frozen-lockfile

- name: "🔨 Build the SDK"
if: steps.changes.outputs.deployRequired == 'true'
if: steps.changes.outputs.deployRequired == 'true' || github.event.inputs.force_deploy == 'true'
run: bun run build:sdk

- name: "👥 Configure AWS Credentials"
if: steps.changes.outputs.deployRequired == 'true'
if: steps.changes.outputs.deployRequired == 'true' || github.event.inputs.force_deploy == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::262732185023:role/github-action-deploy-role
aws-region: eu-west-1
retry-max-attempts: 5

- name: "👥 Login to Amazon ECR"
if: steps.changes.outputs.deployRequired == 'true'
if: steps.changes.outputs.deployRequired == 'true' || github.event.inputs.force_deploy == 'true'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: "🔧 Setup environment"
if: steps.changes.outputs.deployRequired == 'true'
if: steps.changes.outputs.deployRequired == 'true' || github.event.inputs.force_deploy == 'true'
shell: bash
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
Expand All @@ -105,7 +111,7 @@ jobs:
echo "Backend image tag : ${{ env.BACKEND_IMAGE_TAG }}"
- name: "🔨 Build Elysia backend"
if: steps.changes.outputs.backend == 'true'
if: steps.changes.outputs.backend == 'true' || github.event.inputs.force_deploy == 'true'
uses: docker/build-push-action@v6
with:
file: ./infra/docker/ElysiaDockerfile
Expand All @@ -123,7 +129,7 @@ jobs:
STAGE: ${{ env.STAGE }}

- name: "🚀 SST Deploy"
if: steps.changes.outputs.deployRequired == 'true'
if: steps.changes.outputs.deployRequired == 'true' || github.event.inputs.force_deploy == 'true'
run: |
STAGE=${STAGE_OVERRIDE:-$STAGE}
echo "Deploying with stage: $STAGE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ type OnGetProductInformation = IFrameRequestResolver<
*/
export function useOnGetProductInformation(): OnGetProductInformation {
const productId = useAtomValue(listenerProductIdAtom);
const { promise: estimatedRewardAsync } = useEstimatedInteractionReward();
const { promise: productMetadataAsync } = useGetProductMetadata();
const {
estimatedReward: initialEstimatedReward,
refetch: refetchEstimatedReward,
} = useEstimatedInteractionReward();
const {
metadata: initialProductMetadata,
refetch: refetchProductMetadata,
} = useGetProductMetadata();

return useCallback(
async (_request, _context, emitter) => {
const [estimatedReward, productMetadata] = await Promise.all([
estimatedRewardAsync,
productMetadataAsync,
initialEstimatedReward ?? (await refetchEstimatedReward()).data,
initialProductMetadata ?? (await refetchProductMetadata()).data,
]);

if (!(productId && productMetadata)) {
Expand All @@ -51,6 +57,12 @@ export function useOnGetProductInformation(): OnGetProductInformation {
},
});
},
[productId, estimatedRewardAsync, productMetadataAsync]
[
productId,
initialEstimatedReward,
initialProductMetadata,
refetchEstimatedReward,
refetchProductMetadata,
]
);
}

0 comments on commit a71547d

Please sign in to comment.