מדריך למשתמש של gactions

במדריך הזה מוסבר איך להשתמש בכלי ממשק שורת הפקודה (CLI) של gactions בתרחישי שימוש נפוצים. למידע על יצירת פעולות מקצה לקצה, תוכלו לעיין במסמכי Build של פעולות השיחה.

סנכרון פרויקט

כשמשתמשים ב-Actions SDK, אפשר לסנכרן פרויקטים של פעולות בין מסוף Actions לבין מערכת הקבצים המקומית באמצעות gactions.

הפעולות של gactions pull מייצאות פרויקט ממסוף הפעולות למערכת הקבצים המקומית, ופעולות 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

קטע הקוד שלמעלה מראה איך לשלוף פעולה מטיוטת פרויקט. אפשר גם לשלוף מגרסה ספציפית של הפעולה. גרסה מייצגת עותק של פרויקט הפעולות שנשלח, וניתן לפרוס אותו בערוץ הפצה.

הדגל --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 Console.

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

דחיפת פעולות לטיוטה של פרויקט במסוף 'פעולות'

מריצים את הפקודה 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. צריך להחליף את הערך של projectId ברכיב settings.yaml של הפרויקט.
  3. לחלופין, מריצים את gactions push כדי להעתיק את קובצי התצורה המקומית לפרויקט Actions.
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. מידע נוסף על סטטוסים של גרסאות זמין בקובץ העזר State.

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

אם בסטטוס הפריסה כתוב 'היצירה נכשלה', תוכלו לקבל פרטים נוספים על הפריסה בקטע 'גרסה' במסוף.

פריסת פרויקטים

הפקודה gactions deploy מאפשרת לפרוס את הפרויקט כדי לבדוק אותו בסימולטור הפעולות או לפרוס אותו בערוצי גרסאות אלפא/בטא/ייצור.

תצוגה מקדימה בסימולטור

מריצים את 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 כדי ליצור גרסאות לערוצי אלפא/בטא/ייצור שתוכלו לנהל דרך הקטע פריסה במסוף Actions. אפשר להשתמש בו כדי לבדוק גרסאות מועמדות של הפעולה בערוצי האלפא או הבטא, ולהעביר את מועמד הגרסאות לסביבת הייצור אם תהיו מרוצים מהמשוב שלכם.

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 encrypt והפקודות gactions 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