Skip to content

Commit

Permalink
Fix docs access, the token it relied on expired quickly after deploy (#…
Browse files Browse the repository at this point in the history
…353)

* Use an appropriate token for accessing GitHub

* Remove unnecessary log

* Fully replace GITHUB_TOKEN with GH_READ_TOKEN

* :babyrage:

Co-authored-by: Kristers Duģels <[email protected]>

---------

Co-authored-by: Kristers Duģels <[email protected]>
  • Loading branch information
vcarl and kristersd authored Feb 7, 2024
1 parent ac74239 commit 2669c0d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ DISCORD_HASH=<required>
DISCORD_PUBLIC_KEY=<required>
DISCORD_APP_ID=<required>
GUILD_ID=614601782152265748
GITHUB_TOKEN=
GH_READ_TOKEN=
AMPLITUDE_KEY=
OPENAI_KEY=
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
--from-literal=DISCORD_PUBLIC_KEY=${{ secrets.DISCORD_PUBLIC_KEY }} \
--from-literal=DISCORD_APP_ID=${{ secrets.DISCORD_APP_ID }} \
--from-literal=GUILD_ID=${{ secrets.GUILD_ID }} \
--from-literal=GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--from-literal=GH_READ_TOKEN=${{ secrets.GH_READ_TOKEN }} \
--from-literal=AMPLITUDE_KEY=${{ secrets.AMPLITUDE_KEY }} \
--from-literal=OPENAI_KEY=${{ secrets.OPENAI_KEY }} \
|| echo \n
Expand Down
4 changes: 2 additions & 2 deletions cluster/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ spec:
secretKeyRef:
name: reactibot-env
key: DISCORD_HASH
- name: GITHUB_TOKEN
- name: GH_READ_TOKEN
valueFrom:
secretKeyRef:
name: reactibot-env
key: GITHUB_TOKEN
key: GH_READ_TOKEN
- name: AMPLITUDE_KEY
valueFrom:
secretKeyRef:
Expand Down
1 change: 0 additions & 1 deletion src/features/voice-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const voiceActivity = (bot: Client) => {

bot.on("voiceStateUpdate", (oldState, newState) => {
const { member, channel } = newState;
console.log({ member, channel, oldState });
if (!member) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const applicationKey = getEnv("DISCORD_PUBLIC_KEY");
export const applicationId = getEnv("DISCORD_APP_ID");
export const guildId = getEnv("GUILD_ID");
export const discordToken = getEnv("DISCORD_HASH");
export const gitHubToken = getEnv("GITHUB_TOKEN", true);
export const gitHubReadToken = getEnv("GH_READ_TOKEN", true);
export const amplitudeKey = getEnv("AMPLITUDE_KEY", true);
export const openAiKey = getEnv("OPENAI_KEY", true);

Expand Down
4 changes: 2 additions & 2 deletions src/helpers/react-docs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from "node-fetch";
import { gitHubToken } from "./env";
import { gitHubReadToken } from "./env";

const LOOKUP_REGEX = /<Intro>\s*(.*?)\s*<\/Intro>/gs;
const LINK_REGEX = /\[([^\]]+)\]\((?!https?:\/\/)([^)]+)\)/g;
Expand All @@ -13,7 +13,7 @@ export const getReactDocsContent = async (searchPath: string) => {
method: "GET",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${gitHubToken}`,
Authorization: `Bearer ${gitHubReadToken}`,
"X-GitHub-Api-Version": "2022-11-28",
},
});
Expand Down

0 comments on commit 2669c0d

Please sign in to comment.