Skip to content

Commit

Permalink
ci: ensure app exists (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav-Eikaas authored Nov 16, 2023
1 parent edf592c commit a48ea42
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions github-action/src/utils/uploadBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export async function uploadBundle(
) {
const client = new HttpClient();

await ensureAppExists(baseUrl, token, appKey);

const headers: OutgoingHttpHeaders = {
['Authorization']: `Bearer ${token}`,
['Content-Type']: 'application/zip',
Expand Down Expand Up @@ -47,3 +49,21 @@ export async function uploadBundle(
}
logInfo(`Sucessfully published ${appKey}`, 'Green');
}

async function ensureAppExists(baseUrl: string, token: string, appKey: string) {
const client = new HttpClient();

const headers: OutgoingHttpHeaders = {
['Authorization']: `Bearer ${token}`,
['Content-Type']: 'application/zip',
};

const res = await client.get(`${baseUrl}/api/apps/${appKey}?api-version=1.0`, headers);

if (res.message.statusCode === 404) {
logInfo(`Unknown app: ${appKey}`, 'Red');
throw new Error(
'App doesnt exist please use the manual create fusion app to create this app first'
);
}
}

0 comments on commit a48ea42

Please sign in to comment.