gactions 總覽

gactions 指令列介面 (CLI) 工具可協助您建立必要的專案結構和檔案,並將其部署為 Actions 主控台中的 Actions 專案。如要瞭解如何在安裝和設定後使用指令列工具,請改為參閱使用手冊

安裝完成後,您可以在終端機中取得工具功能的摘要:

gactions --help

畫面會出現以下輸出結果:

Command Line Interface for Google Actions SDK

Usage:
  gactions [command]

Available Commands:
  decrypt             Decrypt client secret.
  deploy              Deploy an Action to the specified channel.
  encrypt             Encrypt client secret.
  help                Help about any command
  init                Initialize a directory for a new project.
  login               Authenticate gactions CLI to your Google account via web browser.
  logout              Log gactions CLI out of your Google Account.
  pull                This command pulls files from Actions Console into the local file system.
  push                This command pushes changes in the local files to Actions Console.
  third-party-notices Prints license files of third-party software used.
  version             Prints current version of the CLI.

Flags:
  -h, --help      help for gactions
  -v, --verbose   Display additional error information

Use "gactions [command] --help" for more information about a command.

安裝 gactions 指令列工具

下載安裝套件、解壓縮,並設定執行路徑,藉此安裝 gactions 指令列介面 (CLI) 工具。

如要安裝及設定回應,請按照下列步驟操作:

  1. 下載適用於您作業系統的套件:

    平台 套件 檢查碼
    Windows 下載 SHA256
    Linux 下載 SHA256
    Mac 作業系統 下載 SHA256
  2. 將套件擷取至您選擇的位置,並將二進位檔新增至環境的 PATH 變數。或者,您也可以將套件擷取至 PATH 變數中的現有位置 (例如 /usr/local/bin)。

  3. 在 Linux 和 Mac 上,視需要啟用執行權限:

    chmod +x PATH_TO/gactions
  4. 執行下列指令來驗證 CLI。這個指令會啟動驗證流程,且需要網路瀏覽器:

    gactions login

    流程完成後,CLI 會自動進行驗證。

建立及設定專案

您必須先在「Actions」(動作) 控制台中建立專案,並授予專案回應存取權,才能使用 gactions 指令列工具。如要建立並設定專案,請按照下列步驟操作:

  1. 前往動作控制台
  2. 按一下「新專案」並輸入專案名稱,然後按一下「建立專案」
  3. 選取類別,然後點選「下一步」
  4. 選取「空白專案」,然後按一下「開始建構」
  5. 按照啟用及停用 API 中的操作說明,在 Google Cloud 控制台中啟用 Actions API。這樣一來,回應就會與您的專案互動。

初始化範例

建立空白目錄,然後從該目錄執行 gactions init SAMPLE_NAME,以匯入範例 Actions 專案。您可以使用範例專案做為模型,建立自己的專案並瞭解動作專案的結構。

例如,下列指令會將 hello-world 範例的內容新增至目錄:

gactions init hello-world