gactions 總覽

gactions 指令列介面 (CLI) 工具可協助您建立必要的專案結構和檔案,並以動作主控台的形式部署為 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 主控台建立專案,並授予 Fact 存取專案的權限,才能使用 gactions 指令列工具。如要建立及設定專案,請按照下列步驟操作:

  1. 前往動作控制台
  2. 按一下「新增專案」,輸入專案名稱,然後按一下「建立專案」
  3. 選取類別,然後點選「下一步」
  4. 選取「Blank project」,然後按一下「Start Building」
  5. 按照啟用及停用 API 中的操作說明,在 Google Cloud 控制台中啟用 Actions API。這樣即可指定懸浮動作與專案互動。

初始化範例

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

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

gactions init hello-world