-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
217 additions
and
12 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,45 @@ | ||
import * as c from "std/fmt/colors.ts"; | ||
import { expandGlob } from "std/fs/mod.ts"; | ||
import { Octokit } from "octokit"; | ||
|
||
const ghToken = Deno.env.get("GITHUB_TOKEN"); | ||
const filesGlob = Deno.env.get("FILES_GLOB"); | ||
const releaseId = Deno.env.get("RELEASE_ID"); | ||
|
||
if (!ghToken || !filesGlob || !releaseId) { | ||
console.error("Missing required environment variables"); | ||
Deno.exit(1); | ||
} | ||
|
||
const github = new Octokit({ | ||
auth: ghToken, | ||
}); | ||
|
||
const release = await github.rest.repos.getRelease({ | ||
release_id: Number.parseInt(releaseId, 10), | ||
owner: "Altinn", | ||
repo: "altinn-authorization-utils", | ||
}); | ||
|
||
console.log(`Uploading files to release ${c.cyan(release.data.tag_name)}`); | ||
|
||
for await (const file of expandGlob(filesGlob)) { | ||
const name = file.name; | ||
const path = file.path; | ||
|
||
console.log(`Uploading ${c.yellow(name)}`); | ||
const fs = await Deno.open(path, { read: true }); | ||
|
||
try { | ||
await github.rest.repos.uploadReleaseAsset({ | ||
url: release.data.upload_url, | ||
name, | ||
data: fs as any, | ||
release_id: Number.parseInt(releaseId, 10), | ||
owner: "Altinn", | ||
repo: "altinn-authorization-utils", | ||
}); | ||
} finally { | ||
fs.close(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"imports": { | ||
"std/": "https://deno.land/[email protected]/", | ||
"octokit": "https://esm.sh/v135/[email protected]" | ||
}, | ||
"tasks": { | ||
"esm:add": "deno run -A https://esm.sh/v135 add", | ||
"esm:update": "deno run -A https://esm.sh/v135 update", | ||
"esm:remove": "deno run -A https://esm.sh/v135 remove" | ||
}, | ||
"scopes": { | ||
"https://esm.sh/v135/": { | ||
"@octokit/app": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/core": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/oauth-app": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/plugin-paginate-graphql": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/plugin-paginate-rest": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/plugin-rest-endpoint-methods": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/plugin-retry": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/plugin-throttling": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/request-error": "https://esm.sh/v135/@octokit/[email protected]", | ||
"@octokit/types": "https://esm.sh/v135/@octokit/[email protected]" | ||
} | ||
} | ||
} |
Oops, something went wrong.