Skip to content

Commit 738fc58

Browse files
authored
Merge pull request #7 from ghostdevv/main
Add in github token variable
2 parents 8194fab + a78f0ee commit 738fc58

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ This template comes with jest tests which simply test that the request handler c
3737
`wrangler publish`
3838

3939
For information on how to preview and publish your worker, please see the [Wrangler docs](https://developers.cloudflare.com/workers/tooling/wrangler/commands/#publish).
40+
41+
42+
## Private repos
43+
44+
In order to work with private repos you need to set `GITHUB_TOKEN` variable to your `wrangler.toml` file. You can create a [personal access token here](https://github.com/settings/tokens/new), create it with the repo permissions.

src/handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { sanitizeVersion } from './utils/versioning'
1010
declare global {
1111
const GITHUB_ACCOUNT: string
1212
const GITHUB_REPO: string
13+
const GITHUB_TOKEN: string
1314
}
1415

1516
const responses = {

src/services/github.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export const getReleases = async (request: Request): Promise<Response> => {
77
Accept: 'application/vnd.github.preview',
88
'User-Agent': request.headers.get('User-Agent') as string,
99
})
10+
11+
if (GITHUB_TOKEN?.length) headers.set('Authorization', `token ${GITHUB_TOKEN}`)
12+
1013
return await fetch(reqUrl.toString(), {
1114
method: 'GET',
1215
headers,

wrangler.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ compatibility_date = "2022-03-26"
99
[vars]
1010
GITHUB_ACCOUNT = 'killeencode'
1111
GITHUB_REPO = 'brancato'
12+
GITHUB_TOKEN = '' # Optional - used with private repos
1213

1314
[build]
1415
command = "npm install && npm run build"

0 commit comments

Comments
 (0)