Skip to content

Commit 0f8e6bc

Browse files
committed
fix: pass in GitHub token from workflow
1 parent e9798cd commit 0f8e6bc

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

.github/workflows/build-preview.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
run: "pnpm install"
2929
- name: "build"
3030
run: "pnpm build"
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3133
- name: "copy cloudflare configuration files to build directory"
3234
run: |
3335
cp _headers dist/

.github/workflows/deploy.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
run: "pnpm install"
3131
- name: "build"
3232
run: "pnpm build"
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3335
- name: "copy cloudflare configuration files to build directory"
3436
run: |
3537
cp _headers dist/

src/utils/git.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,22 @@ export interface CommitInfo {
1010
committer: CommitterInfo;
1111
}
1212

13-
const token: string | null = import.meta.env.GITHUB_TOKEN;
13+
const token = process.env.GITHUB_TOKEN;
1414

15-
const options: RequestInit =
16-
token != null
17-
? {
18-
headers: {
19-
Accept: "application/vnd.github+json",
20-
"User-Agent": "papermc-docs/author",
21-
Authorization: `Bearer ${token}`,
22-
},
23-
}
24-
: {
25-
headers: {
26-
Accept: "application/vnd.github+json",
27-
"User-Agent": "papermc-docs/author",
28-
},
29-
};
15+
const options: RequestInit = token
16+
? {
17+
headers: {
18+
Accept: "application/vnd.github+json",
19+
"User-Agent": "papermc-docs/author",
20+
Authorization: `Bearer ${token}`,
21+
},
22+
}
23+
: {
24+
headers: {
25+
Accept: "application/vnd.github+json",
26+
"User-Agent": "papermc-docs/author",
27+
},
28+
};
3029

3130
export const REPO = "PaperMC/docs";
3231
const cache = new Map<string, CommitterInfo>();

0 commit comments

Comments
 (0)