Skip to content

Commit

Permalink
Fix fetching manifest info
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Nov 18, 2023
1 parent 9cbe85e commit e8e4a80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/version_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
permissions:
actions: write
contents: read
packages: read

jobs:
check:
Expand Down
14 changes: 12 additions & 2 deletions scripts/trigger_workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,24 @@ const getLatestVersion = async () => {
throw new Error('Could not determine latest version');
}

const getToken = async () => {
const req = await fetch(`https://ghcr.io/token?scope=repository:popsql/prestodb-sandbox:pull`);
const json = await req.json();
return json.token;
};

const imageExists = async (version) => {
const token = await getToken();
const req = await fetch(`https://ghcr.io/v2/popsql/prestodb-sandbox/manifests/${version}`, {
headers: {
Authorization: `Bearer ${ghToken}`
Authorization: `Bearer ${token}`
}
});
if (!req.ok) {
console.log(await req.json());
const res = await req.json();
if (res.errors?.[0]?.code === 'DENIED') {
throw new Error('Could not fetch image manifest, check that token used is valid');
}
}
return req.ok;
}
Expand Down

0 comments on commit e8e4a80

Please sign in to comment.