Skip to content

Commit

Permalink
chore: update env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 28, 2024
1 parent d4a1bef commit 638537f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
permissions: write-all
env:
TELEGRAM_BOT_ENV: ${{ secrets.TELEGRAM_BOT_ENV }}
STORAGE_APP_ID: ${{ secrets.STORAGE_APP_ID }}
STORAGE_APP_PRIVATE_KEY: ${{ secrets.STORAGE_APP_PRIVATE_KEY }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

steps:
- uses: actions/checkout@v4
Expand All @@ -47,5 +47,5 @@ jobs:
id: Kernel-Telegram
env:
TELEGRAM_BOT_ENV: ${{ secrets.TELEGRAM_BOT_ENV }}
STORAGE_APP_ID: ${{ secrets.STORAGE_APP_ID }}
STORAGE_APP_PRIVATE_KEY: ${{ secrets.STORAGE_APP_PRIVATE_KEY }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
8 changes: 4 additions & 4 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
TELEGRAM_BOT_ENV
STORAGE_APP_ID
STORAGE_APP_PRIVATE_KEY
APP_ID
APP_PRIVATE_KEY
env:
TELEGRAM_BOT_ENV: ${{ secrets.TELEGRAM_BOT_ENV }}
STORAGE_APP_ID: ${{ secrets.STORAGE_APP_ID }}
STORAGE_APP_PRIVATE_KEY: ${{ secrets.STORAGE_APP_PRIVATE_KEY }}
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

- name: Write Deployment URL to Summary
run: |
Expand Down
24 changes: 12 additions & 12 deletions src/bot/mtproto-api/bot/scripts/sms-auth/setup-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ class SetUpHandler {
questions: [
{
type: "input",
name: "STORAGE_APP_ID",
name: "APP_ID",
message:
"Enter your storage app id. This can be obtained from `https://github.com/settings/apps`\n\n This should be saved as an organization secret but we'll save it to the repo too.",
},
{
type: "input",
name: "STORAGE_APP_PRIVATE_KEY",
name: "APP_PRIVATE_KEY",
message:
"Enter your storage app private key. This can be obtained following the instructions in the README. \n\n This should be saved as an organization secret but we'll save it to the repo too.",
},
Expand Down Expand Up @@ -164,8 +164,8 @@ class SetUpHandler {
console.clear();

this.env = {
STORAGE_APP_ID: answers["Storage settings"]["STORAGE_APP_ID"],
STORAGE_APP_PRIVATE_KEY: answers["Storage settings"]["STORAGE_APP_PRIVATE_KEY"],
APP_ID: answers["Storage settings"]["APP_ID"],
APP_PRIVATE_KEY: answers["Storage settings"]["APP_PRIVATE_KEY"],
TELEGRAM_BOT_ENV: {
botSettings: {
TELEGRAM_BOT_ADMINS: JSON.parse(answers["Bot settings"]["TELEGRAM_BOT_ADMINS"]),
Expand Down Expand Up @@ -207,7 +207,7 @@ class SetUpHandler {
console.log(step.title);

const passwords = [
"STORAGE_APP_PRIVATE_KEY",
"APP_PRIVATE_KEY",
"TELEGRAM_BOT_WEBHOOK_SECRET",
"REPO_ADMIN_ACCESS_TOKEN",
"TELEGRAM_API_HASH",
Expand All @@ -234,15 +234,15 @@ class SetUpHandler {
}

async validateEnv() {
const { TELEGRAM_BOT_ENV, STORAGE_APP_PRIVATE_KEY, STORAGE_APP_ID } = this.env;
const { TELEGRAM_BOT_ENV, APP_PRIVATE_KEY, APP_ID } = this.env;
const { botSettings, mtProtoSettings, storageSettings } = TELEGRAM_BOT_ENV;

const merged = {
...botSettings,
...mtProtoSettings,
...storageSettings,
STORAGE_APP_PRIVATE_KEY,
STORAGE_APP_ID,
APP_PRIVATE_KEY,
APP_ID,
};

const keys = Object.keys(merged);
Expand Down Expand Up @@ -272,8 +272,8 @@ class SetUpHandler {

const telegramBotEnv = `TELEGRAM_BOT_ENV=${JSON.stringify(this.env.TELEGRAM_BOT_ENV)}`;
const repositoryEnv = `TELEGRAM_BOT_REPOSITORY_FULL_NAME=${process.env.TELEGRAM_BOT_REPOSITORY_FULL_NAME}`;
const storageAppId = `STORAGE_APP_ID=${this.env.STORAGE_APP_ID}`;
const storageAppPrivateKey = `STORAGE_APP_PRIVATE_KEY=${this.env.STORAGE_APP_PRIVATE_KEY}`;
const storageAppId = `APP_ID=${this.env.APP_ID}`;
const storageAppPrivateKey = `APP_PRIVATE_KEY=${this.env.APP_PRIVATE_KEY}`;

for (const path of paths) {
const envVar = `${repositoryEnv}\n${telegramBotEnv}\n${storageAppId}\n${storageAppPrivateKey}`;
Expand Down Expand Up @@ -330,8 +330,8 @@ class SetUpHandler {
const octokit = new Octokit({ auth: process.env.REPO_ADMIN_ACCESS_TOKEN });
const secrets = {
TELEGRAM_BOT_ENV: this.env.TELEGRAM_BOT_ENV,
STORAGE_APP_ID: this.env.STORAGE_APP_ID,
STORAGE_APP_PRIVATE_KEY: this.env.STORAGE_APP_PRIVATE_KEY,
APP_ID: this.env.APP_ID,
APP_PRIVATE_KEY: this.env.APP_PRIVATE_KEY,
};

try {
Expand Down
4 changes: 2 additions & 2 deletions src/types/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export const env = T.Object({
return str;
})
.Encode((obj) => JSON.stringify(obj)),
STORAGE_APP_ID: T.String(),
STORAGE_APP_PRIVATE_KEY: T.String(),
APP_ID: T.String(),
APP_PRIVATE_KEY: T.String(),
});

export type Env = StaticDecode<typeof env>;
Expand Down
4 changes: 2 additions & 2 deletions src/types/plugin-context-single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export class PluginContext {

getApp() {
try {
const appId = this.env.STORAGE_APP_ID;
const privateKey = this.env.STORAGE_APP_PRIVATE_KEY;
const appId = this.env.APP_ID;
const privateKey = this.env.APP_PRIVATE_KEY;

if (!appId || !privateKey) {
throw new Error("Storage app ID or private key not found");
Expand Down
4 changes: 2 additions & 2 deletions src/workflow-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export async function run() {

const payloadEnv = {
TELEGRAM_BOT_ENV: process.env.TELEGRAM_BOT_ENV,
STORAGE_APP_ID: process.env.STORAGE_APP_ID,
STORAGE_APP_PRIVATE_KEY: process.env.STORAGE_APP_PRIVATE_KEY,
APP_ID: process.env.APP_ID,
APP_PRIVATE_KEY: process.env.APP_PRIVATE_KEY,
};

try {
Expand Down

0 comments on commit 638537f

Please sign in to comment.