Skip to content

Commit

Permalink
🐛 (composable/event-loader) download先を修正, EVENTS_ZIP_URLを.envに追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Shion1305 committed Oct 25, 2023
1 parent 60eedfe commit b9cc493
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-gae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
echo "BASE_URL=/stg/23/tokiwa/" >> .env
fi
# switch service name to configure deployment target appropriately
- name: Download events.json from external URL
- name: Configure events data url
run: |
curl "${{ secrets.EVENTS_DATA_URL }}" -o ./public/data/events.zip
echo "EVENTS_ZIP_URL=${{ secrets.EVENTS_DATA_URL }}" >> .env
- name: yarn install
run: yarn install
- name: yarn build
Expand Down
5 changes: 2 additions & 3 deletions composables/events-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { EventData } from "~/model/eventData";
let events_data: EventData[] = [];

export async function useDataLoader() {
const zipUrl = useRuntimeConfig().public.baseURL + "/data/events.zip";
if (events_data.length > 0) return { events_data };
events_data = await (async function (): Promise<EventData[]> {
const downloaded_data: EventData[] = [];
try {
const zip_data = await fetch("/data/events.zip").then((res) =>
res.blob(),
);
const zip_data = await fetch(zipUrl).then((res) => res.blob());
const zip = await JSZip.loadAsync(zip_data);
const fileNames = Object.keys(zip.files);

Expand Down
5 changes: 5 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ export default defineNuxtConfig({
],
},
},
runtimeConfig: {
publicRuntimeConfig: {
eventsZipURL: process.env.EVENTS_ZIP_URL,
},
},
});

0 comments on commit b9cc493

Please sign in to comment.