คู่มือนี้จะแสดงวิธีใช้เครื่องมืออินเทอร์เฟซบรรทัดคำสั่ง (CLI) ของ gactions ในสถานการณ์การใช้งานทั่วไป สำหรับข้อมูลเกี่ยวกับการสร้างการดำเนินการจากต้นทางถึงปลายทาง โปรดดูเอกสาร สร้าง การดำเนินการแบบการสนทนา
การซิงค์โปรเจ็กต์
เมื่อใช้ Actions SDK gactions จะเป็นเครื่องมือในการซิงค์โปรเจ็กต์ Action ระหว่างคอนโซล Actions กับระบบไฟล์ในเครื่อง
การดำเนินการ gactions pull
จะส่งออกโปรเจ็กต์จากคอนโซล Actions ไปยังระบบไฟล์ในเครื่อง และการดำเนินการ gactions push
จะพุชโปรเจ็กต์จากระบบไฟล์ในเครื่องไปยังคอนโซล 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/sdkls -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 settingsvi 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/sdkls -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
เพื่อนำไฟล์ในเครื่องที่ไม่มีอยู่ในฉบับร่างหรือเวอร์ชันระยะไกลออก ใช้ทั้ง 2 อย่างนี้ร่วมกันเพื่อรับสำเนา
ที่เหมือนของโปรเจ็กต์คอนโซล 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/sdkgactions 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 to 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"
นำเข้าโปรเจ็กต์ที่มีอยู่จากระบบจัดการซอร์สโค้ด
หากต้องการทำงานกับโปรเจ็กต์ที่มีอยู่จากการแก้ไขในระบบควบคุมเวอร์ชัน ให้ทำดังนี้
- ตรวจสอบการแก้ไขเป้าหมาย (ขึ้นอยู่กับระบบ)
- แทนที่ค่า
projectId
ในsettings.yaml
ของโปรเจ็กต์ - (ไม่บังคับ) เรียกใช้
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
เพื่อดูรายละเอียดเกี่ยวกับเวอร์ชันของการดำเนินการ
หากต้องการดูข้อมูลเพิ่มเติมเกี่ยวกับสถานะเวอร์ชัน โปรดดูข้อมูลอ้างอิงสําหรับสถานะ
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
เพื่อสร้างรุ่นเวอร์ชันอัลฟ่า/เบต้า/เวอร์ชัน prod ที่คุณจัดการได้ผ่านส่วนทำให้ใช้งานได้ในคอนโซล 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