-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* integrate with math3d-next APIs * enable legacy save * fewer hardcoded env vars * fix key * test
- Loading branch information
1 parent
3506e51
commit 8035a6e
Showing
4 changed files
with
85 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Deploy | ||
|
||
concurrency: production | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
deployment: | ||
runs-on: ubuntu-latest | ||
environment: production | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }} | ||
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }} | ||
SKIP_YARN_COREPACK_CHECK: true | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.11.1" | ||
cache: "yarn" | ||
- run: npm ci | ||
- run: npm run build | ||
env: | ||
REACT_APP_NEXT_API_CREATE_URL: ${{ vars.REACT_APP_NEXT_API_CREATE_URL }} | ||
REACT_APP_NEXT_API_RETRIEVE_URL: ${{ vars.REACT_APP_NEXT_API_RETRIEVE_URL }} | ||
REACT_APP_DISABLE_LEGACY_SAVE: ${{ vars.REACT_APP_DISABLE_LEGACY_SAVE }} | ||
- run: aws s3 cp --recursive packages/app/dist s3://${{ vars.AWS_S3_BUCKET }}/ | ||
- run: aws cloudfront create-invalidation --distribution-id ${{vars.CLOUDFRONT_DISTRIBUTION_ID}} --paths "/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,55 @@ | ||
// Example api call: | ||
|
||
export const getGraph = async (id) => fetch(`api/graph/${id}`, { | ||
method: 'GET', | ||
headers: {} | ||
} ).then(res => res.json()) | ||
export const getGraph = async (id) => { | ||
if (process.env.REACT_APP_NEXT_API_RETRIEVE_URL) { | ||
return fetch(`${process.env.REACT_APP_NEXT_API_RETRIEVE_URL}${id}`, { | ||
method: "GET", | ||
headers: {}, | ||
}).then((res) => res.json()); | ||
} | ||
return fetch(`api/graph/${id}`, { | ||
method: "GET", | ||
headers: {}, | ||
}).then((res) => res.json()); | ||
}; | ||
|
||
export const saveGraph = async (id, dehydrated) => { | ||
const oldSave = (id, dehydrated) => { | ||
const body = { | ||
urlKey: id, | ||
dehydrated | ||
} | ||
dehydrated, | ||
}; | ||
return fetch(`/api/graph`, { | ||
method: 'POST', | ||
method: "POST", | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(body) | ||
} ).then(res => res.json()) | ||
} | ||
body: JSON.stringify(body), | ||
}).then((res) => res.json()); | ||
}; | ||
|
||
const newSave = async (dehydrated) => { | ||
const data = await fetch(process.env.REACT_APP_NEXT_API_CREATE_URL, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ dehydrated }), | ||
}).then((res) => res.json()); | ||
|
||
if (process.env.REACT_APP_DISABLE_LEGACY_SAVE) { | ||
return data.key; | ||
} | ||
|
||
oldSave(data.key, dehydrated); | ||
|
||
return data.key; | ||
}; | ||
|
||
export const saveGraph = async (id, dehydrated) => { | ||
if (process.env.REACT_APP_NEXT_API_CREATE_URL) { | ||
return newSave(dehydrated); | ||
} else { | ||
await oldSave(id, dehydrated); | ||
return id; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters