Google 操作概览

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) 工具,方法是下载安装软件包,将其解压缩,然后配置执行路径。

如需安装和配置 gaction,请按以下步骤操作:

  1. 下载适用于您的操作系统的软件包:

    平台 软件包 校验和
    Windows 下载 SHA256
    Linux 下载 SHA256
    Mac OS 下载 SHA256
  2. 将该软件包解压缩到您选择的位置,然后将二进制文件添加到环境的 PATH 变量中。或者,将软件包解压缩到 PATH 变量中已有的位置(例如 /usr/local/bin)。

  3. 在 Linux 和 Mac 上,根据需要启用执行权限:

    chmod +x PATH_TO/gactions
  4. 运行以下命令以对 CLI 进行身份验证。此命令会启动身份验证流程,并且需要网络浏览器:

    gactions login

    该流程完成后,CLI 会自动进行身份验证。

创建和设置项目

您必须先在 Actions 控制台中创建一个项目,并向 gactions 授予项目访问权限,然后才能使用 gactions 命令行工具。如需创建和设置项目,请执行以下操作:

  1. 转到 Actions 控制台
  2. 点击 New project,输入项目名称,然后点击 Create project
  3. 选择一个类别,然后点击下一步
  4. 选择 Blank project,然后点击 Start building
  5. 按照启用和停用 API 中的说明,在 Google Cloud 控制台中启用 Actions API。这样,gaction 就可以与您的项目进行交互了。

初始化样本

创建一个空目录,然后从该目录运行 gactions init SAMPLE_NAME,以导入示例 Actions 项目。您可以参考示例项目来创建自己的项目并了解 Actions 项目的结构。

例如,以下命令会将 hello-world 示例的内容添加到您的目录中:

gactions init hello-world