回應使用手冊

本指南說明如何使用 gactions 指令列介面 (CLI) 工具 常見用途如要瞭解如何端對端建構動作,請參閱 對話動作 Build 說明文件。

專案同步處理

使用 Actions SDK 時,gactions 是您同步處理 Action 專案的工具 和本機檔案系統之間的連線

gactions pull 作業會從 Actions 主控台將專案匯出至 本機檔案系統,gactions push 作業會從本機推送專案 新增到 Actions 主控台

從 Actions 主控台下載動作

執行 gactions pull,將 Actions 專案的設定複製到本機 以及檔案系統

您可以透過指令傳遞待複製專案的 project-id 編寫或寫入 settings/settings.yaml 檔案如果兩者同時存在 CLI 會優先採用做為選項傳遞的值。

mkdir -p myAction/sdk
cd myAction/sdk
gactions pull --project-id my-project-id
Pulling your project files from Draft for a project id: "my-project-id"
✔ Done. You should see the files written in path/to/myAction/sdk
ls -l
total 8
drwxr-x---  3 user  primarygroup   96 May  7 10:00 actions
drwxr-x---  4 user  primarygroup  128 May  7 10:00 custom
-rw-r-----  1 user  primarygroup   15 May  7 10:00 manifest.yaml
drwxr-x---  3 user  primarygroup   96 May  7 10:00 settings
vi settings/settings.yaml
// change projectId to "my-other-project-id"
gactions pull
Pulling your project files from Draft for a project id: "my-other-project-id"
path/to/myAction/sdk/manifest.yaml already exists. Would you like to overwrite it?. [y/n]
...
✔ Done. You should see the files written in path/to/myAction/sdk

上方的程式碼片段說明如何從專案草稿中提取動作。是 可擷取特定版本的動作版本 代表您提交的 Actions 專案副本,可部署至 發布版本。

--version-id 旗標會指定要提取的版本,

mkdir -p myAction/sdk
cd myAction/sdk
gactions pull --project-id my-project-id --version-id my-version-id
Pulling version "my-version-id" of the project "my-project-id" from Actions Console...
✔ Done. You should see the files written in path/to/myAction/sdk
ls -l
total 8
drwxr-x---  3 user  primarygroup   96 May  7 10:00 actions
drwxr-x---  4 user  primarygroup  128 May  7 10:00 custom
-rw-r-----  1 user  primarygroup   15 May  7 10:00 manifest.yaml
drwxr-x---  3 user  primarygroup   96 May  7 10:00 settings

如要在不使用任何值的情況下覆寫檔案的本機副本,請使用 --force 旗標 系統就會要求確認使用 --clean 標記移除本機上 不是位於遠端草稿或版本中的檔案。兩者搭配使用, 查看 Actions 主控台專案的完整複本

touch local_file.txt
gactions pull --force
Pulling your project files from Draft for a project id: "my-project-id"
[WARNING] 2020/05/07 17:34:32 path/to/myAction/sdk/local_file.txt is not present in the draft of your Action. To remove, run pull with --clean flag.
✔ Done. You should see the files written in path/to/myAction/sdk
gactions pull --force --clean
Pulling your project files from Draft for a project id: "my-project-id"
[WARNING] 2020/05/07 17:43:44 path/to/myAction/sdk/local_file.txt is not present in the draft of your Action. Removing path/to/myAction/sdk/local_file.txt.
✔ Done. You should see the files written in path/to/myAction/sdk

推送動作至 Actions 主控台專案草稿

執行 gactions push,將變更從本機檔案系統推送至以下版本的草稿: 在控制台中的動作。在開發階段 查看您在 Actions 主控台所做的變更,而不影響 為測試用的版本

gactions push
Pushing your project files to your Actions console draft for a project id: "my-project-id". This may take a few minutes.
Sending configuration files
Waiting for server to respond.
✔ Done. You can now navigate to the Actions Console: https://console.actions.google.com/project/my-project-id/overview to view your project. If you want to test your changes in the simulator, run "gactions deploy preview"

從原始碼管理系統匯入現有專案

如要透過版本管控的修訂版本處理現有專案 系統:

  1. 查看目標修訂版本 (視系統而定)。
  2. 在專案的 settings.yaml 中替換 projectId 的值。
  3. 您也可以執行 gactions push,將本機設定檔複製到 動作專案。
git clone https://github.com/my/repo.git
Cloning into 'repo'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 51 (delta 3), reused 3 (delta 1), pack-reused 41
Receiving objects: 100% (51/51), 36.86 KiB | 3.69 MiB/s, done.
Resolving deltas: 100% (11/11), done.
cd repo/sdk/
vi settings/settings.yaml
// change the value of `projectId`
gactions push

列出版本

執行 gactions versions list 即可查看動作版本的詳細資料。 如要進一步瞭解版本狀態,請參閱狀態參考資料。

gactions versions list
Version         Status          Last Modified By        Modified On     
1           Created     your-email@your-domain.com  2020-09-28 20:22:04

如果部署作業的狀態顯示「建立失敗」,您可以瞭解詳情 只要前往 Play 管理中心的「發布」部分專區。

部署專案

gactions deploy 指令可讓您部署要測試的專案 動作模擬工具或部署到 Alpha/Beta 版/正式版發布版本。

在模擬工具中預覽

執行 gactions deploy preview,將動作部署至「預覽」,即可 您在控制台中測試動作時,不必實際更新 或影響其他開發人員。換句話說, 您在本機檔案系統中所做的變更,都會套用至部署的版本 您的 Actions 專案,但可以在預覽版本上進行測試。

gactions deploy preview
Deploying your project files to your Actions console preview for a project id: "my-project". This may take a few minutes.
Sending configuration files
Waiting for server to respond.
✔ Done. You can now navigate to the Actions Console simulator to test your changes: http://console.actions.google.com/project/my-project/simulator?disableAutoPreview

建立發布版本

執行 gactions deploy 來建立 Alpha/beta/prod 版本的版本 並透過「Actions」控制台的「部署」部分管理這項資訊。 使用這項擴充功能透過 Alpha 和/或 Beta 版測試你的動作候選者 發布新版本,並在確認沒問題後將候選版 以及值得一試

gactions deploy alpha
Deploying your project files to a actions.channels.Alpha channel for a project id: "my-project-id"
Sending configuration files
Waiting for server to respond.
✔ Done. Your Action was deployed to actions.channels.Alpha channel. You can check status of deployment in the Actions Console.

列出發布版本

執行 gactions release-channels list 以查看發布版本的詳細資料 產生關聯您可以使用這個指令 也就是每個管道的部署或待處理狀態

gactions release-channels list
Release Channel             Current Version             Pending Version
alpha                   1                     N/A

帳戶連結

gactions encryptgactions decrypt 指令可讓您管理 OAuth2 用戶端密鑰。這些指令僅適用於帳戶連結

加密 OAuth2 帳戶連結用戶端密鑰

執行 gactions encrypt,安全地新增驗證碼 OAuth2 帳戶的用戶端密鑰 連結流程,或使用新的加密金鑰加密現有密鑰。

gactions encrypt
Write your secret: *********************
Encrypting your client secret
path/to/myAction/sdk/settings/accountLinkingSecret.yaml already exists. Would you like to overwrite it?. [y/n]
y
✔ Done. Encrypted secret was written to path/to/myAction/sdk/settings/accountLinkingSecret.yaml

存取加密帳戶連結密鑰的純文字值。

如需暫時存取 的純文字值,請執行 gactions decrypt 專案的密鑰這個指令會將該值輸出至您選擇的文字檔案。 建議目的地檔案位於專案根資料夾外。 避免純文字值不慎外洩

gactions decrypt ../../burn_after_read.txt
Decrypting your client secret
✔ Done. Check path/above/myActions/burn_after_read.txt to find decrypted client secret.
vi ../../burn_after_read.txt
rm ../../burn_after_read.txt