Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Deno Deploy guide #1081

Merged
merged 17 commits into from
Jul 20, 2024
43 changes: 23 additions & 20 deletions site/docs/hosting/deno-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The result of this tutorial [can be seen in our example bots repository](https:/
> Remember that you need to [run your bot on webhooks](../guide/deployment-types#how-to-use-webhooks), so you should use `webhookCallback` and not call `bot.start()` in your code.

1. Make sure that you have a file which exports your `Bot` object, so that you can import it later to run it.
2. Create a file named `mod.ts` or `mod.js`, or actually any name you like (but you should be remembering and using this as the main file to deploy), with the following content:
2. Create a file named `main.ts` or `main.js`, or actually any name you like (but you should be remembering and using this as the main file to deploy), with the following content:

```ts
import { webhookCallback } from "https://deno.land/x/grammy/mod.ts";
Expand Down Expand Up @@ -59,42 +59,45 @@ Here, we are using the bot token (`/<bot token>`).

> It is recommended that you have a single stable branch and you do your testing stuff in other branches, so that you won't get some unexpected things happen.

3. Visit your [Deno Deploy dashboard](https://dash.deno.com/projects).
4. Click on "New Project", and go to the "Deploy from GitHub repository" section.
3. Visit your [Deno Deploy dashboard](https://dash.deno.com/account/overview).
4. Click on "New Project".
5. Install the GitHub app on your account or organization, and choose your repository.
6. Select the branch you want to deploy, and then choose your `mod.ts` file to be deployed.
6. Select the branch you want to deploy.
7. Select the entrypoint file `main.ts`, and click "Deploy Project" to deploy.

### Method 2: With `deployctl`

> This is a method for more advanced users. It allows you to deploy the project via the command line or Github Actions.
> This is a method for more advanced users or if you don't want to upload your code to GitHub.
> It allows you to deploy the project via the command line or GitHub Actions.

1. Visit your [Deno Deploy dashboard](https://dash.deno.com/projects).
2. Click "New Project", and then "Empty Project".
3. Install [`deployctl`](https://github.com/denoland/deployctl).
4. [Create an access token](https://dash.deno.com/account#access-tokens).
5. Run the following command:
1. Install [`deployctl`](https://github.com/denoland/deployctl).
2. Create an access token from the "Access Tokens" section in [account settings](https://dash.deno.com/account).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The access-token anchor was removed due to the page's lazy loading behavior, so that link-checker doesn't have to be configured to check for the anchor. I think the information is good enough. But if it needs to be reverted, let me know, I can adjust link-checker to ignore this anchor.

3. Go to your project directory and run the following command:

```sh
deployctl deploy --project <project> ./mod.ts --prod --token <token>
```sh:no-line-numbers
deployctl deploy --project=<project> --entrypoint=./main.ts --prod --token=<token>
```

6. To set up Github Actions, refer to [this](https://github.com/denoland/deployctl/blob/main/action/README.md).
::: tip Setting environment variables
Environment variables can be set by heading to your project's settings after deploying.

### Method 3: With URL
But this is possible from the command line, as well:

> All you need for following this method to deploy your grammY bot, is a public URL to your `mod.ts` file.
1. You can assign environment variables from a dotenv file by adding the `--env-file=<file>` argument.
2. You can also specify them individually by using the `--env=<key=value>` argument.

1. Create a new project on Deno Deploy.
2. Click "Deploy URL".
3. Input the public URL to your `mod.ts` file, and click "Deploy".
:::
4. To set up GitHub Actions, refer to [this](https://github.com/denoland/deployctl/blob/main/action/README.md).

Check out the [deployctl documentation](https://docs.deno.com/deploy/manual/deployctl) for more information.

### Note

After getting your app running, you should configure your bot's webhook settings to point to your app.
To do that, send a request to

```text
https://api.telegram.org/bot<token>/setWebhook?url=<url>
```sh:no-line-numbers
curl https://api.telegram.org/bot<token>/setWebhook?url=<url>
```

replacing `<token>` with your bot token, and `<url>` with the full URL of your app along with the path to the webhook handler.
43 changes: 23 additions & 20 deletions site/docs/id/hosting/deno-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Hasil dari tutorial disini dapat dilihat di [repositori bot kami](https://github
> Ingat! Kamu perlu [menjalankan bot dengan webhooks](../guide/deployment-types#bagaimana-cara-menggunakan-webhook), jadi kamu harus menggunakan `webhookCallback` alih-alih memanggil `bot.start()` di kodemu.

1. Pastikan kamu meng-export object bot di dalam sebuah file agar nantinya bisa di-import ketika ingin menjalankannya.
2. Buat sebuah file dengan nama `mod.ts` atau `mod.js`, ataupun nama lainnya sesuai dengan keinginanmu (tetapi kamu harus mengingatnya karena nanti file tersebut akan digunakan sebagai file deploy utama). File tersebut berisikan:
2. Buat sebuah file dengan nama `main.ts` atau `main.js`, ataupun nama lainnya sesuai dengan keinginanmu (tetapi kamu harus mengingatnya karena nanti file tersebut akan digunakan sebagai file deploy utama). File tersebut berisikan:

```ts
import { webhookCallback } from "https://deno.land/x/grammy/mod.ts";
Expand Down Expand Up @@ -62,41 +62,44 @@ Di contoh kali ini, kita menggunakan token bot (`/<token bot>`) sebagai direktor

> Direkomendasikan untuk mempunyai satu branch stabil dan branch lain untuk pengetesan supaya branch utama kamu terhindar dari hal-hal yang tidak diinginkan.

3. Kunjungi [dashboard Deno Deploy](https://dash.deno.com/projects).
4. Pilih "New Project", lalu pergi ke bagian "Deploy from GitHub repository".
3. Kunjungi [dashboard Deno Deploy](https://dash.deno.com/account/overview).
4. Pilih "New Project".
5. Pasang aplikasi GitHub di akun atau organisasimu, kemudian pilih repositori kode bot kamu berada.
6. Pilih branch dan file `mod.ts` yang akan di-deploy.
6. Pilih branch yang akan di-deploy.
7. Pilih file `main.ts` sebagai entrypoint, lalu deploy proyek dengan mengklik "Deploy Project".

### Metode 2: Menggunakan `deployctl`

> Metode ini diperuntukkan kepada pengguna tingkat lanjut yang nantinya proyek akan di-deploy melalui command line atau GitHub Actions.
> Metode ini diperuntukkan untuk penggunaan tingkat lanjut atau jika kamu tidak ingin mengunggah kode proyek ke GitHub.
> Melalui cara ini, kamu bisa men-deploy proyek menggunakan command line atau GitHub Actions.

1. Kunjungi [dashboard Deno Deploy](https://dash.deno.com/projects).
2. Pilih "New Project", kemudian pilih "Empty Project".
3. Pasang [`deployctl`](https://github.com/denoland/deployctl).
4. Buat [token akses](https://dash.deno.com/account#access-tokens) baru.
5. Jalankan dengan perintah:
1. Instal [`deployctl`](https://github.com/denoland/deployctl).
2. Buat sebuah token akses di bagian "Access Tokens", [pengaturan akun](https://dash.deno.com/account).
3. Pergi ke direktori proyek, lalu jalankan perintah berikut:

```sh
deployctl deploy --project <project> ./mod.ts --prod --token <token>
```sh:no-line-numbers
deployctl deploy --project=<project> --entrypoint=./main.ts --prod --token=<token>
```

6. Untuk menyiapkan GitHub Actions, dapat merujuk ke [sini](https://github.com/denoland/deployctl/blob/main/action/README.md).
::: tip Mengatur environment variable
Setelah di-deploy, kamu bisa mengatur environment variable di bagian pengaturan proyek.

### Metode 3: Menggunakan URL
Selain melalui pengaturan proyek, kamu juga bisa mengaturnya melalui command line:

> Kamu memerlukan URL publik yang mengarah ke file `mod.ts`-mu untuk menggunakan metode ini.
1. Taruh semua environment variable di file dotenv, lalu akses dengan menambahkan argumen `--env-file=<file>`.
2. Kamu juga bisa menambahkan environment variable satu per satu menggunakan argumen `--env=<key=value>`.

1. Buat proyek baru di Deno Deploy.
2. Pilih "Deploy URL"
3. Masukkan URL publik file `mod.ts`-mu, lalu pilih "Deploy".
:::
4. Untuk mengatur GitHub Actions, lihat panduan [berikut](https://github.com/denoland/deployctl/blob/main/action/README.md).

Lihat [dokumentasi deployctl](https://docs.deno.com/deploy/manual/deployctl) untuk informasi lebih lanjut.

### Catatan

Setelah mendapati bot-mu dapat berjalan, kamu harus melakukan konfigurasi pada pengaturan webhook untuk menggunakan URL bot-mu yang baru.

```text
https://api.telegram.org/bot<token>/setWebhook?url=<url>
```sh:no-line-numbers
curl https://api.telegram.org/bot<token>/setWebhook?url=<url>
```

Ganti `<token>` dengan token bot-mu, dan `<url>` dengan URL lengkap bot kamu.
44 changes: 24 additions & 20 deletions site/docs/uk/hosting/deno-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Deno Deploy ідеально підходить для більшості про
> Памʼятайте, що вам потрібно [запустити свого бота на вебхуках](../guide/deployment-types#як-використовувати-вебхуки), тому ви повинні використовувати `webhookCallback` і не викликати `bot.start()` у своєму коді.

1. Переконайтеся, що у вас є файл, який експортує ваш обʼєкт `Bot`, щоб ви могли імпортувати його пізніше для запуску.
2. Створіть файл з назвою `mod.ts` або `mod.js` або насправді будь-якою назвою, яку ви хочете, але ви повинні памʼятати та використовувати його як головний файл для розгортання, із наступним вмістом:
2. Створіть файл з назвою `main.ts` або `main.js` або насправді будь-якою назвою, яку ви хочете, але ви повинні памʼятати та використовувати його як головний файл для розгортання, із наступним вмістом:

```ts
import { webhookCallback } from "https://deno.land/x/grammy/mod.ts";
Expand Down Expand Up @@ -59,42 +59,46 @@ Deno.serve(async (req) => {

> Рекомендується мати одну стабільну гілку, а тестувати свої напрацювання в інших гілках, щоб уникнути непередбачуваних помилок.

3. Відвідайте свою [панель керування Deno Deploy](https://dash.deno.com/projects).
4. Натисніть на "New Project" і перейдіть до розділу "Deploy from GitHub repository".
3. Відвідайте свою [панель керування Deno Deploy](https://dash.deno.com/account/overview).
4. Натисніть на "New Project".
5. Встановіть GitHub-застосунок Deno Deploy на свій обліковий запис або організацію та виберіть свій репозиторій.
6. Виберіть гілку, яку ви хочете розгорнути, а потім виберіть файл `mod.ts` для розгортання.
6. Виберіть гілку, яку ви хочете розгорнути.
7. Виберіть вхідний файл `main.ts` і натисніть "Deploy Project", щоб розгорнути проєкт.

### 2-й метод: за допомогою `deployctl`

> Це метод для більш досвідчених користувачів. Він дозволяє розгорнути проєкт за допомогою командного рядка або Github Actions.
> Це метод для більш досвідчених користувачів або якщо ви не хочете розміщувати свій код на GitHub.
> Він дозволяє розгорнути проєкт через командний рядок або GitHub Actions.

1. Відвідайте свою [панель керування Deno Deploy](https://dash.deno.com/projects).
2. Натисніть на "New Project", а потім на "Empty Project".
3. Встановіть [`deployctl`](https://github.com/denoland/deployctl).
4. [Створіть токен доступу](https://dash.deno.com/account#access-tokens).
5. Виконайте наступну команду:
1. Встановіть [`deployctl`](https://github.com/denoland/deployctl).
2. Створіть токен доступу в розділі "Access Tokens" в [налаштуваннях облікового запису](https://dash.deno.com/account).
3. Перейдіть до каталогу вашого проєкту і виконайте наступну команду:

```sh
deployctl deploy --project <назва-проєкту> ./mod.ts --prod --token <токен-доступу>
```sh:no-line-numbers
deployctl deploy --project=<назва-проєкту> --entrypoint=./main.ts --prod --token=<токен-доступу>
```

6. Щоб налаштувати Github Actions, дивіться [це](https://github.com/denoland/deployctl/blob/main/action/README.md).
::: tip Налаштування змінних середовища
Змінні середовища можна встановити, перейшовши до налаштувань вашого проєкту після розгортання.

### 3-й метод: за допомогою URL
Також це можна зробити з командного рядка:

> Все, що вам потрібно зробити, щоб скористатися цим методом для розгортання вашого бота на grammY, --- це отримати публічний URL-адрес вашого файлу `mod.ts`.
1. Ви можете призначити змінні оточення з dotenv-файлу, додавши аргумент `--env-file=<файл>`.
2. Ви також можете вказати їх окремо за допомогою аргументу `--env=<ключ=значення>`.

1. Створіть новий проєкт на Deno Deploy.
2. Натисніть на "Deploy URL".
3. Введіть загальнодоступну URL-адресу вашого файлу `mod.ts` і натисніть на "Deploy".
:::

4. Щоб налаштувати Github Actions, дивіться [це](https://github.com/denoland/deployctl/blob/main/action/README.md).

Перегляньте [документацію deployctl](https://docs.deno.com/deploy/manual/deployctl) для отримання додаткової інформації.

### Примітка

Після запуску застосунку вам потрібно налаштувати вебхук вашого бота так, щоб він вказував на URL-адресу вашого застосунку.
Для цього надішліть запит на адресу

```text
https://api.telegram.org/bot<токен-бота>/setWebhook?url=<адреса>
```sh:no-line-numbers
curl https://api.telegram.org/bot<токен-бота>/setWebhook?url=<адреса>
```

замінивши `<токен-бота>` на токен вашого бота, а `<адреса>` --- на повну URL-адресу вашого застосунку разом з шляхом до обробника вебхуків.
Loading